Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Entity insert statement incorrect with multiple mapped subclasses.

The relationship in question is referencing itself. I didn't have time to test the model, but if you remove the constraint on the database and set logging to ALL you I'm betting you will see that EclipseLink will first insert null into the update_by field and then update the updated_by field in a seperate update statement. If this is indeed occuring, the issue is that when EclipseLink detects a cycle it will perform a shallow insert.

If you can verify that this is the issue, a but already exists for it:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251078

Best Regards,
Chris


On 13/04/2014 9:49 PM, Hal Hildebrand wrote:
Ah.  The zip attachment was scrubbed.  You can find the zipped Maven project here: https://www.dropbox.com/s/1kdprn2ltovqflv/inheritence-test.zip

Because security.

On Apr 13, 2014, at 6:46 PM, Hal Hildebrand <hal.hildebrand@xxxxxx> wrote:

<inheritence-test.zip>

I went ahead and created a stand-alone test case for this.  i’m using Postgresql, but as this seems to be an EclipseLink issue I’m pretty darn confident it would fail if tried against Oracle.  In any event, it looks like this isn’t just a Tiffin Phantasm of whatever complexity I have in my code base.

The standalone test case is attached (inheritance-test.zip).  This project requires maven 3.x.  To run:

    cd inheritance-test
    mvn clean install

Hopefully, it’s obvious which properties in the pom.xml you’ll need to either override or replace to get this to work against your Postgresql database.  If not, please feel free to ask for clarification.

Again, please note that this *does* work when using OpenJPA.  I’m not sure who’s at fault here, or if there’s just ambiguity in the spec, or if I’m just another Bozo on this bus (actually, my mother was a Bozoette in college…).  But this is something that I need to figure out in order to port to TopLink.

Any help is appreciated.

When Running the test, the error output is:

Running com.chiralbehaviors.CoRE.DrinkMeTest
[EL Info]: 2014-04-13 18:40:08.924--ServerSession(1097996400)--EclipseLink, version: Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5
[EL Info]: connection: 2014-04-13 18:40:09.08--ServerSession(1097996400)--file:/Users/hhildebrand/git/Ultrastructure/inheritence-test/target/classes/_inheritence-test_url=jdbc:postgresql://192.168.56.101:5432/test_user=postgres login successful
[EL Warning]: 2014-04-13 18:40:09.193--UnitOfWork(2130840085)--Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: null value in column "updated_by" violates not-null constraint
  Detail: Failing row contains (1, CoRE, null, null, null, null, 0).
Error Code: 0
Call: INSERT INTO test.agency (id, description, name, notes, pinned, update_date, updated_by) VALUES (?, ?, ?, ?, ?, ?, ?)
	bind => [7 parameters bound]
Query: WriteObjectQuery(Agency [name=CoRE, id=1])
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.53 sec <<< FAILURE!
inheritenceTest(com.chiralbehaviors.CoRE.DrinkMeTest)  Time elapsed: 0.094 sec  <<< ERROR!
javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: org.postgresql.util.PSQLException: ERROR: null value in column "updated_by" violates not-null constraint
  Detail: Failing row contains (1, CoRE, null, null, null, null, 0).
Error Code: 0
Call: INSERT INTO test.agency (id, description, name, notes, pinned, update_date, updated_by) VALUES (?, ?, ?, ?, ?, ?, ?)
	bind => [7 parameters bound]
Query: WriteObjectQuery(Agency [name=CoRE, id=1])
	at org.eclipse.persistence.internal.jpa.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:157)
	at com.chiralbehaviors.CoRE.DrinkMeTest.inheritenceTest(DrinkMeTest.java:53)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users



Back to the top