Andrus Adamchik <andru..bjectstyle.org> wrote:
> Going through the mailing list archive, I can see that you are using
> Cayenne for real in your apps... In this case everything should be even
> simpler. Forget configuring DataSource in struts XML files. Whenever
> you *really-really* need to bypass Cayenne and get connections directly
> do something like this:
>
> DataNode node =
> (DataNode)Configuration.getDomain().getDataNodes().get(0);
> DataSource ds = node.getDataSource();
If it's not obvious (it wasn't to me when I needed it for dbunit), you'll
want to typecast that datasource to PoolManager:
PoolManager dataSource = (PoolManager) dataNode.getDataSource();
For what it's worth, you can also use this code to get a DataNode if you
want to be more certain of which data node you're getting back:
ObjEntity anObjEntity =
aDataContext.getEntityResolver().lookupObjEntity(SOME_DATA_OBJECT.getObjectId().getObjClass());
DataNode dataNode = aDataContext.dataNodeForObjEntity(anObjEntity);
I don't configure Cayenne using the struts XML files either, but also use it
directly.
-Mike
This archive was generated by hypermail 2.0.0 : Thu Nov 06 2003 - 22:31:36 EST