[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openejb-user
Subject:    Re: Unit Testing with openEjb
From:       "Kevin Sutter" <kwsutter () gmail ! com>
Date:       2008-12-11 21:03:51
Message-ID: 89c0c52c0812111303x302fc17fx8ef4193c57f23ebf () mail ! gmail ! com
[Download RAW message or body]


Hi Sanga,
I need a couple of clarifications to help diagnose your situation.  If I'm
reading this right, you are attempting to run your test with and without the
following property in your persistence.xml.  Is that right?

<properties>
          <property name="openjpa.jdbc.SynchronizeMappings"
value="buildSchema(ForeignKeys=true)" />
</properties>

This property tells OpenJPA to use the mappings defined by your object model
(Entity annotations and/or xml) and then make the database schema "right".
The documentation for this option can be found here:
http://openjpa.apache.org/builds/1.2.0/apache-openjpa-1.2.0/docs/manual/manual.html#ref_guide_mapping_mappingtool(the
 mapping tool options are used for the SynchronizeMappings property).

But, from your note below, it sounds like you are using an existing
application and database, so you probably don't want to modify the schema
dynamically with that option.  You might want to use the "validate" option
instead of the "buildSchema" to ensure that your object mappings do match
your schema definitions.  If they do not match, then an error message should
be produced that will explain the differences.

Let's start with that.  Take a look at the OpenJPA doc reference that I
provided, try out the validate option for the SynchronizeMappings, and let's
determine if we're in the right ball park before we go much further.
Providing your Entity mappings may also help with diagnosing the situation.

Thanks,
Kevin

On Wed, Dec 10, 2008 at 12:40 PM, David Blevins <david.blevins@visi.com>wrote:

> Hi Sanga,
> 
> Hoping the OpenJPA folks have some insight on the error.
> 
> -David
> 
> On Dec 9, 2008, at 2:35 AM, sanga lawalata wrote:
> 
> Greetings,
> > 
> > I know the problem is that there is no in my persistence XML.
> > 
> > <properties>
> > <property name="openjpa.jdbc.SynchronizeMappings"
> > value="buildSchema(ForeignKeys=true)" />
> > </properties>
> > 
> > 
> > but I get problems here that in DB :
> > Table User (number id, varchar name, number address_id). And the
> > address_id
> > can be null.
> > Table Address(number id, varchar description)
> > 
> > I map the User table into entity UserBean for example and set my addressId
> > as null because I dont need it.
> > 
> > if i delete in my persitence.xml the "xml fragment upstair (property
> > fragment)", i will get  error message
> > 
> > <openjpa-1.1.0-r422266:659716 nonfatal general error>
> > org.apache.openjpa.persistence.PersistenceException: null
> > at
> > 
> > org.apache.openjpa.jdbc.kernel.AbstractJDBCSeq.getConnection(AbstractJDBCSeq.java:162)
> >  at
> > 
> > org.apache.openjpa.jdbc.kernel.NativeJDBCSeq.nextInternal(NativeJDBCSeq.java:209)
> > 
> > If I put  in my persitence.xml the "xml fragment upstair (property
> > fragment)", i will get  error message
> > <openjpa-1.1.0-r422266:659716 nonfatal general error>
> > org.apache.openjpa.persistence.PersistenceException: Table "User" has a
> > foreign key to table "Address" that has not been generated.  You must run
> > the schema generator on all inter-related tables at once.
> > 
> > i just want to insert and delete into User table using UserEntity and set
> > the addressId as null because later addressId can be taken from another
> > class who deals with it. (I am working with already existing application
> > and
> > db).
> > 
> > Any advice guys to deal with this situation ??
> > 
> > best regards
> > sanga lawalata
> > 
> 
> 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic