This is strange, OpenJPA created new table that I specified in second unit to the database of first persistence unit.
1. I have fun the find command, I only have one persistence.xml 2. There is not property set in my persistence.xml to ask openjpa to create table if not exists. Kevin Sutter wrote: > > On Tue, Feb 10, 2009 at 12:31 PM, bongosdude <[email protected]> wrote: > >> >> Kevin, >> >> I have turned on the SQL trace and did not see any hints why this >> happened. > > > The format of your logging property doesn't look right, so that might be > reason why the output doesn't give any hints. :-) Maybe the "tmp" is > ignored. Not sure. Try something like this: > > <property name="openjpa.Log" value="DefaultLevel=TRACE"/> > > This will turn on all Tracing, not just the SQL tracing. This might help > explain why the extra entities and persistence units are getting > processed. > > > Entities in the second units are defined but there are not >> session API to access it yet. And I do not set any properties to >> create table at all. OpenJPA see that the tables in the second unit do >> not exists in the first unit and try to create in the first unit. > > > Very strange. Have not experienced that. > > >> >> What are the work around solution? > > > Except for separating the persistence units into separate persistence.xml > files, I'm not sure at this point. This is a new problem for me, so I'm > not > sure how or why you are experiencing it. > > Kevin > >> >> >> -B >> On Feb 10, 2009, at 12:57 PM, Kevin Sutter (via Nabble) wrote: >> >> > Hi, >> > A situation similar to this was first reported to me back in August >> > by the >> > author of an IBM Redbook ( >> > >> http://www.redbooks.ibm.com/Redbooks.nsf/RedpieceAbstracts/sg247639.html?Open >> ) >> > . >> > After I gave the "standard" answers of how this might be happening, >> > I never >> > heard back. So, I don't know if the problem was resolved by >> > application >> > review or if they decided to live with the situation or what they >> > did. You >> > might want to reference the Redbook to see if there's any reference >> > to the >> > situation. >> > >> > First off, the tables should only be created if you are using the >> > SynchronizeMappings property. Since I don't see that in your >> > persistence.xml, then I don't see how the tables are getting created >> > automatically. Unless you have a different version of the >> > persistence.xml >> > file that is getting picked up somehow. Or, maybe your build >> > process is >> > invoking the MappingTool? Not sure. I have never experienced >> > anything like >> > that. >> > >> > As far as creating the empty tables... My guess is that your junit >> > test is >> > (accidentally?) touching both entities, thus creating both tables. >> > If you >> > turn on the complete openjpa trace, you can see the processing of the >> > entities within each persistence unit. So, either the entities are >> > being >> > specified via some property or they are being touched by your >> > application. >> > That's my guess. The trace would give more data to go off of. >> > >> > IIRC, there is one limitation with the MappingTool and/or >> > SynchronizeMappings that it will only process the entities in the >> > first >> > defined persistence unit within a persistence.xml file. But, even >> > that >> > doesn't seem to apply in this case since you are indicating that the >> > tables >> > are getting created via the second persistence unit. >> > >> > Hopefully, the trace will show who is accessing what and causing the >> > entity >> > processing and table creation. >> > >> > Good luck, >> > Kevin >> > >> > >> > On Tue, Feb 10, 2009 at 11:36 AM, bongosdude <bongosd...@...> wrote: >> > >> > > >> > > I defined two persistence units in my persistence.xml to connect >> > to two >> > > different databases (one is MySQL and other to MS SQL) like below >> > > >> > > <persistence xmlns="http://java.sun.com/xml/ns/persistence" >> > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >> > > version="1.0" >> > > >> xsi:schemaLocation="http://java.sun.com/xml/ns/persistence >> > > http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> >> > > <persistence-unit name="CallingCardUsersUnit"> >> > > <description>Entity Beans to db1</description> >> > > >> > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ >> > provider> >> > > <non-jta-data-source>db_users_notx</non-jta-data-source> >> > > >> > <class>com.xyz.services.app.model.entity.users.User</class> >> > > >> > > <class>com.xyz.services.app.model.entity.users.UserRole</class> >> > > >> > > <class>com.xyz.services.app.model.entity.users.UserAccount</class> >> > > <properties> >> > > <property name="/tmp/openjpa.log" >> > value="SQL=TRACE" >> > > /> >> > > </properties> >> > > </persistence-unit> >> > > >> > > <persistence-unit name="DigittalkUnit"> >> > > <description>Entity Beans for db2</description> >> > > >> > > <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</ >> > provider> >> > > <non-jta-data-source>billing_notx</non-jta-data-source> >> > > <class>com.xyz.services.app.model.entity.billing.BUser</ >> > class> >> > > <class>com.xyz.services.app.model.entity.billing.BAccount</ >> > class> >> > > <properties> >> > > <property name="/tmp/openjpa.log" >> > value="SQL=TRACE" >> > > /> >> > > </properties> >> > > </persistence-unit> >> > > >> > > >> > > </persistence> >> > > >> > > >> > > When my app first starts up and runs, I need to access entity >> > > com.xyz.services.app.model.entity.users.User, JPA tries to load >> > entiry >> > > com.xyz.services.app.model.entity.users.User and then it tries to >> > create >> > > table BUser and BAccount in the first persistence unit. BUser and >> > BAccount >> > > are listed in second persistence unit. Also, BUser and BAccount >> > are mapped >> > > to existing tables in second persistence unit. >> > > >> > > Can someone help me since I do not understand why it happens. >> > Also, How can >> > > I turn of the auto create table. >> > > >> > > Thanks >> > > -B >> > > -- >> > > View this message in context: >> > > >> http://n2.nabble.com/Problem-with-multi-persistence-units-tp2303818p2303818.html >> > > Sent from the OpenJPA Users mailing list archive at Nabble.com. >> > > >> > > >> > >> > >> > This email is a reply to your post @ >> http://n2.nabble.com/Problem-with-multi-persistence-units-tp2303818p2303948.html >> > You can reply by email or by visting the link above. >> > >> >> >> -- >> View this message in context: >> http://n2.nabble.com/Problem-with-multi-persistence-units-tp2303818p2304147.html >> Sent from the OpenJPA Users mailing list archive at Nabble.com. >> > > -- View this message in context: http://n2.nabble.com/Problem-with-multi-persistence-units-tp2303818p2304438.html Sent from the OpenJPA Users mailing list archive at Nabble.com.
