tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Blevins <david.blev...@visi.com>
Subject Re: Configuring DataSources in a managed environment
Date Mon, 17 Dec 2007 21:41:06 GMT

On Dec 17, 2007, at 7:19 AM, Alexander Saint Croix wrote:

> Thanks for the help, David.
>
> I broke up the component library to make it modular, as there are  
> presently
> between 70-100 entities total.

Ok, just to be clear though, you cannot have managed relationships to  
entities outside your unit.  Forgetting all things packaging, a unit  
is one cache of data managed by the Provider.  The provider cannot see  
or manage data (including relationships) outside the unit (i.e. its  
cache).  It's fine to break your units up just as long as you're doing  
it consciously and deliberately with that in mind.

> Do my component JARs need to have persistence.xml files at all?   
> None of
> them are the root of the persistence unit--that seems to be the WAR.
> Shouldn't I define the persistence.xml file in the web app and  
> reference the
> JARs from there?  It would certainly simplify matters.

If you put your persistence.xml in the webapp and listed your 70-100  
persistent classes in it, you could spread the classes into as many  
WEB-INF/lib jars as you like.  Doing this is essentially feeding the  
provider all the class names it should make persistent and not relying  
on the jar searching for the @Entity annotation.  There might be a  
better option, but that is one approach I know should work.

> Also, in which file do I configure my DataSource in embedded OpenEJB?

In your openejb.xml via:

   <Resource id="myJtaDatasource" type="DataSource">
      JdbcDriver  = com.mysql.jdbc.Driver
      JdbcUrl     = jdbc:mysql://localhost/corm
      UserName    = root
      Password    = n00p455wyrd
   </Resource>

   <Resource id="myNonJtaDatasource" type="DataSource">
      JdbcDriver  = com.mysql.jdbc.Driver
      JdbcUrl     = jdbc:mysql://localhost/corm
      UserName    = root
      Password    = n00p455wyrd
      JtaManaged  = false
   </Resource>

Note that JtaManaged only works in trunk, so if you're using beta 1  
you'll need to declare myNonJtaDatasource as follows:

   <Resource id="myNonJtaDatasource" type="DataSource"  
provider="Default Unmanaged JDBC Database">
      JdbcDriver  = com.mysql.jdbc.Driver
      JdbcUrl     = jdbc:mysql://localhost/corm
      UserName    = root
      Password    = n00p455wyrd
   </Resource>


-David


Mime
View raw message