openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Philippe Alexis" <>
Subject Re: [jira] Commented: (OPENJPA-231) Incorrect handling of cascading bidirectional collections during merge/attach
Date Sun, 13 May 2007 19:29:18 GMT
Hi Gokhan,

I'd been busy with work but kept this particular issue at the back of my
mind for coming back to.
How far did you get investigating it?

Firstly, I had no problem getting updateAttached (EntityManager em) to run
fine on both SQL Server and Postgresql,
got the count of 4.

For updateDetached (EntityManager em), I was able to get it to 'work' by
allowing cascading from C to B on the @ManyToOne

>From the lack of response to this issue, I'm thinking this might be a design
decision the bigger picture of which is eluding me.
Anyone would care to shed some light on this, why @ManyToOne(cascade=
CascadeType.ALL) solves the problem reported?

On MySQL, updateDetached works fine with the modification:

But for updateAttached, the issue of apparently attempting to save instances
of C before those of B persists with and without
the above change:
     [java] Caused by: <0.9.7-incubating fatal general error>
org.apache.openjpa.persistence.PersistenceException: The transaction has
been rolled back.  See the nested exceptions for details on the errors that
     [java] at org.apache.openjpa.kernel.BrokerImpl.newFlushException(
     [java] at org.apache.openjpa.kernel.BrokerImpl.flush(
     [java] at org.apache.openjpa.kernel.BrokerImpl.flushSafe(
     [java] at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(
     [java] at org.apache.openjpa.kernel.LocalManagedRuntime.commit(
     [java] at org.apache.openjpa.kernel.BrokerImpl.commit(
     [java] at org.apache.openjpa.kernel.DelegatingBroker.commit(
     [java] at org.apache.openjpa.persistence.EntityManagerImpl.commit(
     [java] ... 23 more
     [java] Caused by: <0.9.7-incubating nonfatal general error>
org.apache.openjpa.persistence.PersistenceException: Cannot add or update a
child row: a foreign key constraint fails (`test/test_c`, CONSTRAINT
(`B_ID`)) {prepstmnt 7832149 INSERT INTO TEST_C (c_id, B_ID) VALUES (?, ?)
[params=(int) 4, (int) 4]} [code=1452, state=23000]
     [java] FailedObject: test.C@1236cd5
     [java] at org.apache.openjpa.jdbc.sql.DBDictionary.newStoreException(
     [java] at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
     [java] at org.apache.openjpa.jdbc.sql.SQLExceptions.getStore(
     [java] at
     [java] at
     [java] at
     [java] at
     [java] at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
     [java] at org.apache.openjpa.jdbc.kernel.AbstractUpdateManager.flush(
     [java] at org.apache.openjpa.jdbc.kernel.JDBCStoreManager.flush(
     [java] at org.apache.openjpa.kernel.DelegatingStoreManager.flush(
     [java] ... 30 more
     [java] Caused by: org.apache.openjpa.lib.jdbc.ReportingSQLException:
Cannot add or update a child row: a foreign key constraint fails
REFERENCES `test_b` (`B_ID`)) {prepstmnt 7832149 INSERT INTO TEST_C (c_id,
B_ID) VALUES (?, ?) [params=(int) 4, (int) 4]} [code=1452, state=23000]
     [java] at org.apache.openjpa.lib.jdbc.LoggingConnectionDecorator.wrap(
     [java] at
     [java] at
     [java] at
     [java] at
     [java] at
     [java] ... 37 more


On 5/4/07, Gokhan Ergul <> wrote:
> Philippe,
> I must admit I'm quite illiterate when it comes to Eclipse --ditched it
> a long time ago in favor of Idea. You must be right about the build.xml
> being a not-so-straightforward root for Eclipse import, it didn't occur
> to me that it could be used that way. Having said that, here's my
> (purely speculative) comments about the problem you're having:
> > [java] javax.persistence.PersistenceException: Invalid or inaccessible
> > provider class: org.apache.openjpa.persistence.PersistenceProviderImpl
> >     [java] at
> >
> That sure looks like a classpath problem to me, and the fact that it's
> coming from ant..ExecuteJava is somewhat telling, the Eclipse-generated
> build.xml is running a <java ..> task instead of an <openjpac> task,
> possibly with a different classpath.
> > Is the use of <taskdef name="openjpac" classname="
> > org.apache.openjpa.ant.PCEnhancerTask"/>
> > the equivalent of what is done for the examples with
> >
> > <!--
> >                Specifying the openjpa jar as the javaagent argument is
> >                necessary in order for automatic class-enhancement to
> > work.
> >            -->
> >            <jvmarg value="-javaagent:${javaagent}"/>    ?
> <openjpac> task performs a build-time class enhancement, whereas the
> "-javaagent" method performs a run-time enhancement, you can use either
> as long as the environment is setup properly. Since the above exception
> is coming from a <java> task, I'm assuming you're using run-time
> enhancement method, then it boils down to setting the correct classpath
> entries.
> If you can post the relevant parts of your build.xml, it'll be easier to
> spot the problem.
> Gokhan.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message