Affects: Release Notes project_key: JBPAPP6 I think this problem occurs because Hibernate is not able to apply correct Lock Mode.If the database does not support the requested lock mode, Hibernate should use an appropriate alternate mode (instead of throwing an exception) to ensure that applications will be portable. On Oracle Dbs: ErrorMessage: Caused by: java.sql.SQLSyntaxErrorException: ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc. at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) Query at error:select parententi0_.id as id1378_, parententi0_.REV as REV1378_, parententi0_.REVTYPE as REVTYPE1378_, parententi0_.REVEND as REVEND1378_, parententi0_.data as data1378_, parententi0_.numVal as numVal1379_, parententi0_.clazz_ as clazz_ from ( select id, REV, REVTYPE, REVEND, data, null as numVal, 0 as clazz_ from ParentEntity_AUD union all select id, REV, REVTYPE, REVEND, data, numVal, 1 as clazz_ from ChildEntity_AUD ) parententi0_ where parententi0_.id=? and (parententi0_.REVEND is null) for update On Mssql2008R1 and R2: ErrorMessage: Caused by: org.hibernate.exception.SQLGrammarException: Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon. at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122) Query at Error: select parententi0_.id as id622_, parententi0_.REV as REV622_, parententi0_.REVTYPE as REVTYPE622_, parententi0_.REVEND as REVEND622_, parententi0_.data as data622_, parententi0_.numVal as numVal623_, parententi0_.clazz_ as clazz_ from ( select id, REV, REVTYPE, REVEND, data, null as numVal, 0 as clazz_ from ParentEntity_AUD union all select id, REV, REVTYPE, REVEND, data, numVal, 1 as clazz_ from ChildEntity_AUD ) parententi0_ with (updlock, rowlock) where parententi0_.id=? and (parententi0_.REVEND is null) PostGRESQl: ErrorMessage: Caused by: org.hibernate.exception.GenericJDBCException: ERROR: SELECT FOR UPDATE/SHARE cannot be applied to the nullable side of an outer join at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) Query at error: select parententi0_.id as id2782_, parententi0_.REV as REV2782_, parententi0_.REVTYPE as REVTYPE2782_, parententi0_.REVEND as REVEND2782_, parententi0_.data as data2782_, parententi0_1_.numVal as numVal2783_, case when parententi0_1_.id is not null then 1 when parententi0_.id is not null then 0 end as clazz_ from ParentEntity_AUD parententi0_ left outer join ChildEntity_AUD parententi0_1_ on parententi0_.id=parententi0_1_.id and parententi0_.REV=parententi0_1_.REV where parententi0_.id=? and ( parententi0_.REVEND is null ) for update
Workaround Description: Added: On Oracle Dbs: ErrorMessage: Caused by: java.sql.SQLSyntaxErrorException: ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc. at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) Query at error:select parententi0_.id as id1378_, parententi0_.REV as REV1378_, parententi0_.REVTYPE as REVTYPE1378_, parententi0_.REVEND as REVEND1378_, parententi0_.data as data1378_, parententi0_.numVal as numVal1379_, parententi0_.clazz_ as clazz_ from ( select id, REV, REVTYPE, REVEND, data, null as numVal, 0 as clazz_ from ParentEntity_AUD union all select id, REV, REVTYPE, REVEND, data, numVal, 1 as clazz_ from ChildEntity_AUD ) parententi0_ where parententi0_.id=? and (parententi0_.REVEND is null) for update
Such a query cannot be handled by Oracle. As there is a union the query will get rid of duplicates and hence the resulting set is not updateable.
Workaround Description: Removed: On Oracle Dbs: ErrorMessage: Caused by: java.sql.SQLSyntaxErrorException: ORA-02014: cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc. at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:91) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) Query at error:select parententi0_.id as id1378_, parententi0_.REV as REV1378_, parententi0_.REVTYPE as REVTYPE1378_, parententi0_.REVEND as REVEND1378_, parententi0_.data as data1378_, parententi0_.numVal as numVal1379_, parententi0_.clazz_ as clazz_ from ( select id, REV, REVTYPE, REVEND, data, null as numVal, 0 as clazz_ from ParentEntity_AUD union all select id, REV, REVTYPE, REVEND, data, numVal, 1 as clazz_ from ChildEntity_AUD ) parententi0_ where parententi0_.id=? and (parententi0_.REVEND is null) for update
created https://hibernate.onjira.com/browse/HHH-7295
Could not disagree more about Hibernate switching to an alternate lock type. This is a lock type the user has explicitly requested. In terms of Envers usage, *maybe* we somehow allow Envers to decide between different lock types to achieve whatever it is trying to achieve here. We'll have to discuss with Adam and Lukasz to understand the intent here a little better.
Link: Added: This issue is a dependency of JBPAPP-8827
Link: Added: This issue is a dependency of JBPAPP-9292
Link: Removed: This issue is a dependency of JBPAPP-8827
Release Notes Docs Status: Added: Documented as Resolved Issue Release Notes Text: Added: The <code>ParentAuditing</code> test in Hibernate Envers failed across all databases with different messages because the LockMode was not set correctly. The Hibernate code was updated to fix this issue, and the LockMode is now set correctly. Affects: Added: Release Notes
Verified.
Writer: Added: mistysj
Release Notes Text: Removed: The <code>ParentAuditing</code> test in Hibernate Envers failed across all databases with different messages because the LockMode was not set correctly. The Hibernate code was updated to fix this issue, and the LockMode is now set correctly. Added: The `ParentAuditing` test in Hibernate Envers failed across all databases with different messages because the `LockMode` was not set correctly. The Hibernate code was updated to fix this issue, and the `LockMode` is now set correctly.
Release Notes Docs Status: Removed: Documented as Resolved Issue Writer: Removed: mistysj Release Notes Text: Removed: The `ParentAuditing` test in Hibernate Envers failed across all databases with different messages because the `LockMode` was not set correctly. The Hibernate code was updated to fix this issue, and the `LockMode` is now set correctly. Docs QE Status: Removed: NEW