Community
Participate
Working Groups
Build Identifier: 2.3.2.v20111125-r10461 Bulk update does not work while updating entity from hierarchy Reproducible: Always Steps to Reproduce: 1. Create project which contains the following hierarchy of entites @Entity @DiscriminatorColumn(name = "class") @Table(name = "mo") @Inheritance(strategy= InheritanceType.JOINED) public class SuperObject { @Column(name = "name") private String name; @Version @Column(name = "version") private int version; } @Entity @Table(name = "e") public class EntityDBImpl extends ManagedObjectDBImpl { @Column(name = "ind") private int entityIndex; } 2. Execute the following bulk update: em.createQuery("UPDATE EntityDBImpl p SET p.name = 'f3'").executeUpdate(); 3. Executing of this query throws the following exception: [EL Fine]: 2012-06-25 11:12:52.666--ClientSession(211201404)--Connection(39723566)--Thread(Thread[main,5,main])--UPDATE mo SET version = (SELECT (t1.version + ?) FROM mo t0, e t1 WHERE ((t1.id = t0.id) AND (t0.class IN (?, ?, ?, ?))) AND t0.id = mo.id), name = ? WHERE EXISTS(SELECT t0.id FROM mo t0, e t1 WHERE ((t1.id = t0.id) AND (t0.class IN (?, ?, ?, ?))) AND t0.id = mo.id) bind => [1, PortDBImpl, PortF3DBImpl, ModuleDBImpl, PortF7DBImpl, f3, PortDBImpl, PortF3DBImpl, ModuleDBImpl, PortF7DBImpl] Local Exception Stack: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: org.postgresql.util.PSQLException: ERROR: column t1.version does not exist Pozycja: 34 Error Code: 0 Call: UPDATE mo SET version = (SELECT (t1.version + ?) FROM mo t0, e t1 WHERE ((t1.id = t0.id) AND (t0.class IN (?, ?, ?, ?))) AND t0.id = mo.id), name = ? WHERE EXISTS(SELECT t0.id FROM mo t0, e t1 WHERE ((t1.id = t0.id) AND (t0.class IN (?, ?, ?, ?))) AND t0.id = mo.id) bind => [1, PortDBImpl, PortF3DBImpl, ModuleDBImpl, PortF7DBImpl, f3, PortDBImpl, PortF3DBImpl, ModuleDBImpl, PortF7DBImpl] Query: UpdateAllQuery(referenceClass=EntityDBImpl sql="UPDATE mo SET version = (SELECT (t1.version + ?) FROM mo t0, e t1 WHERE ((t1.id = t0.id) AND (t0.class IN (?, ?, ?, ?))) AND t0.id = mo.id), name = ? WHERE EXISTS(SELECT t0.id FROM mo t0, e t1 WHERE ((t1.id = t0.id) AND (t0.class IN (?, ?, ?, ?))) AND t0.id = mo.id)") at org.eclipse.persistence.exceptions.DatabaseException.sqlException(DatabaseException.java:333) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.processExceptionForCommError(DatabaseAccessor.java:1494) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:838) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeNoSelect(DatabaseAccessor.java:906) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:592) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:535) at org.eclipse.persistence.internal.sessions.AbstractSession.basicExecuteCall(AbstractSession.java:1717) at org.eclipse.persistence.sessions.server.ClientSession.executeCall(ClientSession.java:253) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:207) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:193) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeNoSelectCall(DatasourceCallQueryMechanism.java:236) at org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.updateAll(DatasourceCallQueryMechanism.java:787) at org.eclipse.persistence.queries.UpdateAllQuery.executeDatabaseQuery(UpdateAllQuery.java:153) at org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:844) at org.eclipse.persistence.queries.DatabaseQuery.executeInUnitOfWork(DatabaseQuery.java:743) at org.eclipse.persistence.queries.ModifyAllQuery.executeInUnitOfWork(ModifyAllQuery.java:145) at org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2871) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1516) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1498) at org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1463) at org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeUpdate(EJBQueryImpl.java:540) at com.adva.nlms.LockingTest.testVersionOnBulkUpdate(LockingTest.java:98) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:74) at org.testng.internal.Invoker.invokeMethod(Invoker.java:673) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:846) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1170) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:1125) at org.testng.TestRunner.privateRun(TestRunner.java:749) at org.testng.TestRunner.run(TestRunner.java:600) at org.testng.SuiteRunner.runTest(SuiteRunner.java:317) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:312) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:274) at org.testng.SuiteRunner.run(SuiteRunner.java:223) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1007) at org.testng.TestNG.runSuitesLocally(TestNG.java:932) at org.testng.TestNG.run(TestNG.java:868) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:110) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:205) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:174) at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:111) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) Caused by: org.postgresql.util.PSQLException: ERROR: column t1.version does not exist Pozycja: 34 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334) at org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(DatabaseAccessor.java:831) ... 50 more
I assume in your example EntityDBImpl should actually extend SuperObject
Yes, EntityDBImpl should extend SuperObject.
Setting target and priority. See the following page for the meanings of these fields: http://wiki.eclipse.org/EclipseLink/Development/Bugs/Guidelines Community: Please vote for this bug if it is important to you. Votes are one of the main criteria we use to determine which bugs to fix next.
The Eclipselink project has moved to Github: https://github.com/eclipse-ee4j/eclipselink