Bug 900346 (JBPAPP6-901) - ParentAuditing Test in Envers Testsuite fails across all databases with different error messages because Hibernate does not set LockMode correctly
Summary: ParentAuditing Test in Envers Testsuite fails across all databases with diffe...
Keywords:
Status: CLOSED NEXTRELEASE
Alias: JBPAPP6-901
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Hibernate
Version: 6.0.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: ---
: EAP 6.0.1
Assignee: Strong Liu
QA Contact:
URL: http://jira.jboss.org/jira/browse/JBP...
Whiteboard:
Depends On:
Blocks: JBPAPP6-905
TreeView+ depends on / blocked
 
Reported: 2012-05-02 12:30 UTC by Madhumita Sadhukhan
Modified: 2014-06-28 12:34 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-10-29 05:47:24 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker JBPAPP6-901 0 Major Closed ParentAuditing Test in Envers Testsuite fails across all databases with different error messages because Hibernate does ... 2013-10-16 17:48:00 UTC

Description Madhumita Sadhukhan 2012-05-02 12:30:34 UTC
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

Comment 1 Madhumita Sadhukhan 2012-05-02 12:35:41 UTC
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


Comment 2 Madhumita Sadhukhan 2012-05-02 12:45:56 UTC
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.



Comment 3 Madhumita Sadhukhan 2012-05-02 13:01:37 UTC
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 


Comment 4 Madhumita Sadhukhan 2012-05-02 14:41:47 UTC
created https://hibernate.onjira.com/browse/HHH-7295 

Comment 5 Steve Ebersole 2012-05-02 15:50:46 UTC
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.

Comment 6 Rajesh Rajasekaran 2012-05-02 19:09:59 UTC
Link: Added: This issue is a dependency of JBPAPP-8827


Comment 7 Rajesh Rajasekaran 2012-06-06 22:26:14 UTC
Link: Added: This issue is a dependency of JBPAPP-9292


Comment 8 Rajesh Rajasekaran 2012-06-06 22:26:44 UTC
Link: Removed: This issue is a dependency of JBPAPP-8827 


Comment 9 Misty Stanley-Jones 2012-06-12 11:08:36 UTC
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


Comment 10 Zbyněk Roubalík 2012-10-04 09:30:52 UTC
Verified.

Comment 11 Dana Mison 2012-10-16 05:22:31 UTC
Writer: Added: mistysj


Comment 12 Dana Mison 2012-10-29 05:47:16 UTC
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.


Comment 13 Anne-Louise Tangring 2012-11-13 20:07:46 UTC
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 



Note You need to log in before you can comment on or make changes to this bug.