[hibernate-issues] [Hibernate-JIRA] Created: (HHH-5293) Envers doesn't adequately support the PrimaryKeyJoinColumn
Ken Lowther (JIRA)
noreply at atlassian.com
Fri Jun 4 17:39:37 EDT 2010
Envers doesn't adequately support the PrimaryKeyJoinColumn
----------------------------------------------------------
Key: HHH-5293
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5293
Project: Hibernate Core
Issue Type: Bug
Components: envers
Affects Versions: 3.2.4.sp1
Environment: Windows XP, JBoss 4.2.2, Envers 1.2.1.GA, Oracle 10g
Reporter: Ken Lowther
Attachments: PrimaryKeyJoinColumn1.jar
A parent/child entity pair are joined by the @PrimaryKeyJoinColumn annotation in the child class. When inserting an audit row into the child entity's corresponding audit table, the child entity uses the name of the parent's primary key instead of its own primary key. The value is the same, but the column names may be different.
The attached test case uses Widget (parent) and RedWidget (child) to illustrate this issue. Here is the generated SQL:
insert
into
WIDGET_AUD
(REVTYPE, WIDGET_DESC, WIDGET_ID, REV)
values
(?, ?, ?, ?)
Hibernate:
insert
into
RED_WIDGET_AUD
(RED_WIDGET_PROPERTY, WIDGET_ID, REV)
values
(?, ?, ?)
The following exception is returned when an insert of the RedWidget committed:
WARN logExceptions, SQL Error: 904, SQLState: 42000
ERROR logExceptions, ORA-00904: "WIDGET_ID": invalid identifier
ERROR performExecutions, Could not synchronize database state with session
org.hibernate.exception.SQLGrammarException: could not insert: [org.jboss.envers.test.entities.RedWidgetEntity_AUD]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:90)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2285)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2678)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:79)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:167)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1028)
at org.hibernate.envers.synchronization.AuditSync.beforeCompletion(AuditSync.java:167)
at org.hibernate.transaction.JDBCTransaction.notifyLocalSynchsBeforeTransactionCompletion(JDBCTransaction.java:274)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:140)
at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:54)
at org.jboss.envers.test.PrimaryKeyJoinColumnTest.initData(PrimaryKeyJoinColumnTest.java:29)
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.MethodHelper.invokeMethod(MethodHelper.java:580)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:398)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:145)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:82)
at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:167)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:104)
at org.testng.TestRunner.runWorkers(TestRunner.java:712)
at org.testng.TestRunner.privateRun(TestRunner.java:582)
at org.testng.TestRunner.run(TestRunner.java:477)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:324)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:319)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292)
at org.testng.SuiteRunner.run(SuiteRunner.java:198)
at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:823)
at org.testng.TestNG.runSuitesLocally(TestNG.java:790)
at org.testng.TestNG.run(TestNG.java:708)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:124)
Caused by: java.sql.SQLException: ORA-00904: "WIDGET_ID": invalid identifier
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:145)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:789)
at oracle.jdbc.driver.T2CConnection.checkError(T2CConnection.java:715)
at oracle.jdbc.driver.T2CPreparedStatement.executeForDescribe(T2CPreparedStatement.java:605)
at oracle.jdbc.driver.T2CPreparedStatement.executeForRows(T2CPreparedStatement.java:843)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1270)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3415)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3498)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2268)
... 35 more
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list