-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Incorrect delete statement generation
PostPosted: Wed Apr 30, 2008 10:25 am 
Newbie

Joined: Fri Jun 15, 2007 2:32 pm
Posts: 16
I am trying to execute a delete statement on a table with a where clause that requires Hibernate to create a join.

If I execute a select with the same where the query is generated correctly.

Here are the working select and the non-working delete statements:

Code:
entityManager.createQuery("select dodm from DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1")
      .setParameter(1, getTaskId())
      .getResultList();
entityManager.createQuery("delete DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1")
      .setParameter(1, getTaskId())
      .executeUpdate();


Here is the output (showsql) of the two statements:

Code:
Hibernate:
    /* select
        dodm
    from
        DatabaseObjectDataMapping dodm
    where
        dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1 */ select
            databaseob0_.COLUMN_NAME as COLUMN1_89_,
            databaseob0_.DATABASE_OBJECT_DATA_ID as DATABASE4_89_,
            databaseob0_.COLUMN_MAPPING as COLUMN2_89_,
            databaseob0_.USE_SOURCE as USE3_89_
        from
            database_object_data_mapping databaseob0_,
            database_object_data databaseob1_
        where
            databaseob0_.DATABASE_OBJECT_DATA_ID=databaseob1_.DATABASE_OBJECT_DATA_ID
            and databaseob1_.TASK_ID=?
Hibernate:
    delete
    from
        database_object_data_mapping,
        database_object_data databaseob1_
    where
        TASK_ID=?
16:57:08 WARN  JDBCExceptionReporter - SQL Error: 933, SQLState: 42000
16:57:08 ERROR JDBCExceptionReporter - ORA-00933: SQL command not properly ended


The delete statement was supposed to be generated like so:

Code:
delete from
(select
            dodm.COLUMN_NAME as COLUMN1_89_,
            dodm.DATABASE_OBJECT_DATA_ID as DATABASE4_89_,
            dodm.COLUMN_MAPPING as COLUMN2_89_,
            dodm.USE_SOURCE as USE3_89_
        from
            database_object_data_mapping dodm,
            database_object_data dod
        where
            dodm.DATABASE_OBJECT_DATA_ID=dod.DATABASE_OBJECT_DATA_ID
            and dod.TASK_ID=1)


Hibernate version:

Hibernate Annotations 3.3.1.GA
Hibernate 3.2.6.GA
Hibernate EntityManager 3.3.2.GA

This is debug level log of starting with the execution of the select statement and than the delete statement:

17:00:11 DEBUG QueryPlanCache - unable to locate HQL query plan in cache; generating (select dodm from DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1)
17:00:11 DEBUG QueryTranslatorImpl - parse() - HQL: select dodm from com.comp.main.service.beans.persistence.DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1
17:00:11 DEBUG AST - --- HQL AST ---
\-[QUERY] 'query'
+-[SELECT_FROM] 'SELECT_FROM'
| +-[FROM] 'from'
| | \-[RANGE] 'RANGE'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[DOT] '.'
| | | | | | | +-[DOT] '.'
| | | | | | | | +-[IDENT] 'com'
| | | | | | | | \-[IDENT] 'comp'
| | | | | | | \-[IDENT] 'main'
| | | | | | \-[IDENT] 'service'
| | | | | \-[IDENT] 'beans'
| | | | \-[IDENT] 'persistence'
| | | \-[IDENT] 'DatabaseObjectDataMapping'
| | \-[ALIAS] 'dodm'
| \-[SELECT] 'select'
| \-[IDENT] 'dodm'
\-[WHERE] 'where'
\-[EQ] '='
+-[DOT] '.'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[IDENT] 'dodm'
| | | | \-[IDENT] 'databaseObjectDataMappingPK'
| | | \-[IDENT] 'databaseObjectData'
| | \-[IDENT] 'task'
| \-[IDENT] 'taskId'
\-[PARAM] '?'
\-[NUM_INT] '1'

17:00:11 DEBUG ErrorCounter - throwQueryException() : no errors
17:00:11 DEBUG HqlSqlBaseWalker - select << begin [level=1, statement=select]
17:00:11 DEBUG FromElement - FromClause{level=1} : com.comp.main.service.beans.persistence.DatabaseObjectDataMapping (dodm) -> databaseob0_
17:00:11 DEBUG FromReferenceNode - Resolved : dodm -> (databaseob0_.COLUMN_NAME, databaseob0_.DATABASE_OBJECT_DATA_ID)
17:00:11 DEBUG FromReferenceNode - Resolved : dodm -> (databaseob0_.COLUMN_NAME, databaseob0_.DATABASE_OBJECT_DATA_ID)
17:00:11 DEBUG FromElement - handling property dereference [com.comp.main.service.beans.persistence.DatabaseObjectDataMapping (dodm) -> databaseObjectDataMappingPK (class)]
17:00:11 DEBUG DotNode - getDataType() : databaseObjectDataMappingPK -> org.hibernate.type.ComponentType@d9cc1a
17:00:11 DEBUG DotNode - Unresolved property path is now 'databaseObjectDataMappingPK.databaseObjectData'
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK -> databaseob0_.DATABASE_OBJECT_DATA_ID
17:00:11 DEBUG DotNode - getDataType() : databaseObjectDataMappingPK.databaseObjectData -> org.hibernate.type.ManyToOneType(com.comp.main.service.beans.persistence.DatabaseObjectData)
17:00:11 DEBUG DotNode - dereferenceEntityJoin() : generating join for databaseObjectData in com.comp.main.service.beans.persistence.DatabaseObjectDataMapping {no alias} parent = [ ( . ( . ( databaseob0_.DATABASE_OBJECT_DATA_ID (databaseob0_.COLUMN_NAME, databaseob0_.DATABASE_OBJECT_DATA_ID) databaseObjectDataMappingPK ) databaseObjectData ) task ) ]
17:00:11 DEBUG FromElement - FromClause{level=1} : com.comp.main.service.beans.persistence.DatabaseObjectData (no alias) -> databaseob1_
17:00:11 DEBUG FromClause - addJoinByPathMap() : dodm.databaseObjectDataMappingPK.databaseObjectData -> database_object_data databaseob1_
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK.databaseObjectData -> databaseob0_.DATABASE_OBJECT_DATA_ID
17:00:11 DEBUG FromElement - handling property dereference [com.comp.main.service.beans.persistence.DatabaseObjectData (null) -> task (class)]
17:00:11 DEBUG DotNode - getDataType() : task -> org.hibernate.type.ManyToOneType(com.comp.main.service.beans.persistence.Task)
17:00:11 DEBUG DotNode - dereferenceShortcut() : property taskId in com.comp.main.service.beans.persistence.DatabaseObjectData does not require a join.
17:00:11 DEBUG DotNode - Unresolved property path is now 'task.taskId'
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK.databaseObjectData.task -> databaseob1_.TASK_ID
17:00:11 DEBUG DotNode - getDataType() : task.taskId -> org.hibernate.type.IntegerType@79a340
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId -> databaseob1_.TASK_ID
17:00:11 DEBUG HqlSqlBaseWalker - select : finishing up [level=1, statement=select]
17:00:11 DEBUG HqlSqlWalker - processQuery() : ( SELECT ( {select clause} (databaseob0_.COLUMN_NAME, databaseob0_.DATABASE_OBJECT_DATA_ID) ) ( FromClause{level=1} database_object_data_mapping databaseob0_ database_object_data databaseob1_ ) ( where ( = ( databaseob1_.TASK_ID ( databaseob1_.TASK_ID ( databaseob0_.DATABASE_OBJECT_DATA_ID ( databaseob0_.DATABASE_OBJECT_DATA_ID (databaseob0_.COLUMN_NAME, databaseob0_.DATABASE_OBJECT_DATA_ID) databaseObjectDataMappingPK ) databaseObjectData ) task ) taskId ) ? ) ) )
17:00:11 DEBUG JoinProcessor - Using FROM fragment [database_object_data_mapping databaseob0_]
17:00:11 DEBUG SyntheticAndFactory - Using WHERE fragment [databaseob0_.DATABASE_OBJECT_DATA_ID=databaseob1_.DATABASE_OBJECT_DATA_ID]
17:00:11 DEBUG HqlSqlBaseWalker - select >> end [level=1, statement=select]
17:00:11 DEBUG AST - --- SQL AST ---
\-[SELECT] QueryNode: 'SELECT' querySpaces (database_object_data,database_object_data_mapping)
+-[SELECT_CLAUSE] SelectClause: '{select clause}'
| +-[ALIAS_REF] IdentNode: 'databaseob0_.COLUMN_NAME as COLUMN1_29_, databaseob0_.DATABASE_OBJECT_DATA_ID as DATABASE4_29_' {alias=dodm, className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping, tableAlias=databaseob0_}
| \-[SQL_TOKEN] SqlFragment: 'databaseob0_.COLUMN_MAPPING as COLUMN2_29_, databaseob0_.USE_SOURCE as USE3_29_'
+-[FROM] FromClause: 'from' FromClause{level=1, fromElementCounter=2, fromElements=2, fromElementByClassAlias=[dodm], fromElementByTableAlias=[databaseob0_, databaseob1_], fromElementsByPath=[dodm.databaseObjectDataMappingPK.databaseObjectData], collectionJoinFromElementsByPath=[], impliedElements=[]}
| +-[FROM_FRAGMENT] FromElement: 'database_object_data_mapping databaseob0_' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=dodm,role=null,tableName=database_object_data_mapping,tableAlias=databaseob0_,origin=null,colums={,className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping}}
| \-[FROM_FRAGMENT] ImpliedFromElement: 'database_object_data databaseob1_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=database_object_data,tableAlias=databaseob1_,origin=database_object_data_mapping databaseob0_,colums={databaseob0_.DATABASE_OBJECT_DATA_ID ,className=com.comp.main.service.beans.persistence.DatabaseObjectData}}
\-[WHERE] SqlNode: 'where'
+-[THETA_JOINS] SqlNode: '{theta joins}'
| \-[SQL_TOKEN] SqlFragment: 'databaseob0_.DATABASE_OBJECT_DATA_ID=databaseob1_.DATABASE_OBJECT_DATA_ID'
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'databaseob1_.TASK_ID' {propertyName=taskId,dereferenceType=4,propertyPath=task.taskId,path=dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId,tableAlias=databaseob1_,className=com.comp.main.service.beans.persistence.DatabaseObjectData,classAlias=null}
| +-[DOT] DotNode: 'databaseob1_.TASK_ID' {propertyName=taskId,dereferenceType=ROOT_LEVEL,propertyPath=task.taskId,path=dodm.databaseObjectDataMappingPK.databaseObjectData.task,tableAlias=databaseob1_,className=com.comp.main.service.beans.persistence.DatabaseObjectData,classAlias=null}
| | +-[DOT] DotNode: 'databaseob0_.DATABASE_OBJECT_DATA_ID' {propertyName=databaseObjectData,dereferenceType=1,propertyPath=databaseObjectDataMappingPK.databaseObjectData,path=dodm.databaseObjectDataMappingPK.databaseObjectData,tableAlias=databaseob1_,className=com.comp.main.service.beans.persistence.DatabaseObjectData,classAlias=null}
| | | +-[DOT] DotNode: 'databaseob0_.DATABASE_OBJECT_DATA_ID' {propertyName=databaseObjectData,dereferenceType=2,propertyPath=databaseObjectDataMappingPK.databaseObjectData,path=dodm.databaseObjectDataMappingPK,tableAlias=databaseob0_,className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping,classAlias=dodm}
| | | | +-[ALIAS_REF] IdentNode: '(databaseob0_.COLUMN_NAME, databaseob0_.DATABASE_OBJECT_DATA_ID)' {alias=dodm, className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping, tableAlias=databaseob0_}
| | | | \-[IDENT] IdentNode: 'databaseObjectDataMappingPK' {originalText=databaseObjectDataMappingPK}
| | | \-[IDENT] IdentNode: 'databaseObjectData' {originalText=databaseObjectData}
| | \-[IDENT] IdentNode: 'task' {originalText=task}
| \-[IDENT] IdentNode: 'taskId' {originalText=taskId}
\-[NAMED_PARAM] ParameterNode: '?' {name=1, expectedType=org.hibernate.type.IntegerType@79a340}

17:00:11 DEBUG ErrorCounter - throwQueryException() : no errors
17:00:11 DEBUG QueryTranslatorImpl - HQL: select dodm from com.comp.main.service.beans.persistence.DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1
17:00:11 DEBUG QueryTranslatorImpl - SQL: select databaseob0_.COLUMN_NAME as COLUMN1_29_, databaseob0_.DATABASE_OBJECT_DATA_ID as DATABASE4_29_, databaseob0_.COLUMN_MAPPING as COLUMN2_29_, databaseob0_.USE_SOURCE as USE3_29_ from database_object_data_mapping databaseob0_, database_object_data databaseob1_ where databaseob0_.DATABASE_OBJECT_DATA_ID=databaseob1_.DATABASE_OBJECT_DATA_ID and databaseob1_.TASK_ID=?
17:00:11 DEBUG ErrorCounter - throwQueryException() : no errors
17:00:11 DEBUG HQLQueryPlan - HQL param location recognition took 0 mills (select dodm from DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1)
17:00:11 DEBUG QueryPlanCache - located HQL query plan in cache (select dodm from DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1)
17:00:11 DEBUG HQLQueryPlan - find: select dodm from DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1
17:00:11 DEBUG QueryParameters - named parameters: {1=304}
17:00:11 DEBUG AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:00:11 DEBUG SQL -
/* select
dodm
from
DatabaseObjectDataMapping dodm
where
dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1 */ select
databaseob0_.COLUMN_NAME as COLUMN1_29_,
databaseob0_.DATABASE_OBJECT_DATA_ID as DATABASE4_29_,
databaseob0_.COLUMN_MAPPING as COLUMN2_29_,
databaseob0_.USE_SOURCE as USE3_29_
from
database_object_data_mapping databaseob0_,
database_object_data databaseob1_
where
databaseob0_.DATABASE_OBJECT_DATA_ID=databaseob1_.DATABASE_OBJECT_DATA_ID
and databaseob1_.TASK_ID=?
Hibernate:
/* select
dodm
from
DatabaseObjectDataMapping dodm
where
dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1 */ select
databaseob0_.COLUMN_NAME as COLUMN1_29_,
databaseob0_.DATABASE_OBJECT_DATA_ID as DATABASE4_29_,
databaseob0_.COLUMN_MAPPING as COLUMN2_29_,
databaseob0_.USE_SOURCE as USE3_29_
from
database_object_data_mapping databaseob0_,
database_object_data databaseob1_
where
databaseob0_.DATABASE_OBJECT_DATA_ID=databaseob1_.DATABASE_OBJECT_DATA_ID
and databaseob1_.TASK_ID=?
17:00:11 DEBUG AbstractBatcher - preparing statement
17:00:11 DEBUG IntegerType - binding '304' to parameter: 1
17:00:11 DEBUG AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
17:00:11 DEBUG Loader - processing result set
17:00:11 DEBUG Loader - done processing result set (0 rows)
17:00:11 DEBUG AbstractBatcher - about to close ResultSet (open ResultSets: 1, globally: 1)
17:00:11 DEBUG AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:00:11 DEBUG AbstractBatcher - closing statement
17:00:11 DEBUG Loader - total objects hydrated: 0
17:00:11 DEBUG StatefulPersistenceContext - initializing non-lazy collections
17:00:11 DEBUG QueryPlanCache - unable to locate HQL query plan in cache; generating (delete DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1)
17:00:11 DEBUG QueryTranslatorImpl - parse() - HQL: delete com.comp.main.service.beans.persistence.DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1
17:00:11 DEBUG AST - --- HQL AST ---
\-[DELETE] 'delete'
+-[FROM] 'FROM'
| \-[RANGE] 'RANGE'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[DOT] '.'
| | | | | +-[DOT] '.'
| | | | | | +-[DOT] '.'
| | | | | | | +-[IDENT] 'com'
| | | | | | | \-[IDENT] 'comp'
| | | | | | \-[IDENT] 'main'
| | | | | \-[IDENT] 'service'
| | | | \-[IDENT] 'beans'
| | | \-[IDENT] 'persistence'
| | \-[IDENT] 'DatabaseObjectDataMapping'
| \-[ALIAS] 'dodm'
\-[WHERE] 'where'
\-[EQ] '='
+-[DOT] '.'
| +-[DOT] '.'
| | +-[DOT] '.'
| | | +-[DOT] '.'
| | | | +-[IDENT] 'dodm'
| | | | \-[IDENT] 'databaseObjectDataMappingPK'
| | | \-[IDENT] 'databaseObjectData'
| | \-[IDENT] 'task'
| \-[IDENT] 'taskId'
\-[PARAM] '?'
\-[NUM_INT] '1'

17:00:11 DEBUG ErrorCounter - throwQueryException() : no errors
17:00:11 DEBUG HqlSqlBaseWalker - delete << begin [level=1, statement=delete]
17:00:11 DEBUG FromElement - FromClause{level=1} : com.comp.main.service.beans.persistence.DatabaseObjectDataMapping (dodm) -> databaseob0_
17:00:11 DEBUG FromReferenceNode - Resolved : dodm -> (COLUMN_NAME, DATABASE_OBJECT_DATA_ID)
17:00:11 DEBUG FromElement - handling property dereference [com.comp.main.service.beans.persistence.DatabaseObjectDataMapping (dodm) -> databaseObjectDataMappingPK (class)]
17:00:11 DEBUG DotNode - getDataType() : databaseObjectDataMappingPK -> org.hibernate.type.ComponentType@d9cc1a
17:00:11 DEBUG DotNode - Unresolved property path is now 'databaseObjectDataMappingPK.databaseObjectData'
17:00:11 DEBUG FromElementType - Using non-qualified column reference [databaseObjectDataMappingPK.databaseObjectData -> ([DATABASE_OBJECT_DATA_ID])]
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK -> DATABASE_OBJECT_DATA_ID
17:00:11 DEBUG DotNode - getDataType() : databaseObjectDataMappingPK.databaseObjectData -> org.hibernate.type.ManyToOneType(com.comp.main.service.beans.persistence.DatabaseObjectData)
17:00:11 DEBUG DotNode - dereferenceEntityJoin() : generating join for databaseObjectData in com.comp.main.service.beans.persistence.DatabaseObjectDataMapping {no alias} parent = [ ( . ( . ( DATABASE_OBJECT_DATA_ID (COLUMN_NAME, DATABASE_OBJECT_DATA_ID) databaseObjectDataMappingPK ) databaseObjectData ) task ) ]
17:00:11 DEBUG FromElementType - Using non-qualified column reference [databaseObjectDataMappingPK.databaseObjectData -> ([DATABASE_OBJECT_DATA_ID])]
17:00:11 DEBUG FromElement - FromClause{level=1} : com.comp.main.service.beans.persistence.DatabaseObjectData (no alias) -> databaseob1_
17:00:11 DEBUG FromClause - addJoinByPathMap() : dodm.databaseObjectDataMappingPK.databaseObjectData -> database_object_data databaseob1_
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK.databaseObjectData -> DATABASE_OBJECT_DATA_ID
17:00:11 DEBUG FromElement - handling property dereference [com.comp.main.service.beans.persistence.DatabaseObjectData (null) -> task (class)]
17:00:11 DEBUG DotNode - getDataType() : task -> org.hibernate.type.ManyToOneType(com.comp.main.service.beans.persistence.Task)
17:00:11 DEBUG DotNode - dereferenceShortcut() : property taskId in com.comp.main.service.beans.persistence.DatabaseObjectData does not require a join.
17:00:11 DEBUG FromElementType - Using non-qualified column reference [task -> ([TASK_ID])]
17:00:11 DEBUG DotNode - Unresolved property path is now 'task.taskId'
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK.databaseObjectData.task -> TASK_ID
17:00:11 DEBUG DotNode - getDataType() : task.taskId -> org.hibernate.type.IntegerType@79a340
17:00:11 DEBUG FromReferenceNode - Resolved : dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId -> TASK_ID
17:00:11 DEBUG HqlSqlBaseWalker - delete : finishing up [level=1, statement=delete]
17:00:11 DEBUG HqlSqlBaseWalker - delete >> end [level=1, statement=delete]
17:00:11 DEBUG AST - --- SQL AST ---
\-[DELETE] DeleteStatement: 'delete' querySpaces (database_object_data,database_object_data_mapping)
+-[FROM] FromClause: 'FROM' FromClause{level=1, fromElementCounter=2, fromElements=2, fromElementByClassAlias=[dodm], fromElementByTableAlias=[databaseob0_, databaseob1_], fromElementsByPath=[dodm.databaseObjectDataMappingPK.databaseObjectData], collectionJoinFromElementsByPath=[], impliedElements=[]}
| +-[FROM_FRAGMENT] FromElement: 'database_object_data_mapping' FromElement{explicit,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=dodm,role=null,tableName=database_object_data_mapping,tableAlias=databaseob0_,origin=null,colums={,className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping}}
| \-[JOIN_FRAGMENT] ImpliedFromElement: 'database_object_data databaseob1_' ImpliedFromElement{implied,not a collection join,not a fetch join,fetch non-lazy properties,classAlias=null,role=null,tableName=database_object_data,tableAlias=databaseob1_,origin=database_object_data_mapping,colums={DATABASE_OBJECT_DATA_ID ,className=com.comp.main.service.beans.persistence.DatabaseObjectData}}
\-[WHERE] SqlNode: 'where'
\-[EQ] BinaryLogicOperatorNode: '='
+-[DOT] DotNode: 'TASK_ID' {propertyName=taskId,dereferenceType=4,propertyPath=task.taskId,path=dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId,tableAlias=databaseob1_,className=com.comp.main.service.beans.persistence.DatabaseObjectData,classAlias=null}
| +-[DOT] DotNode: 'TASK_ID' {propertyName=taskId,dereferenceType=ROOT_LEVEL,propertyPath=task.taskId,path=dodm.databaseObjectDataMappingPK.databaseObjectData.task,tableAlias=databaseob1_,className=com.comp.main.service.beans.persistence.DatabaseObjectData,classAlias=null}
| | +-[DOT] DotNode: 'DATABASE_OBJECT_DATA_ID' {propertyName=databaseObjectData,dereferenceType=1,propertyPath=databaseObjectDataMappingPK.databaseObjectData,path=dodm.databaseObjectDataMappingPK.databaseObjectData,tableAlias=databaseob1_,className=com.comp.main.service.beans.persistence.DatabaseObjectData,classAlias=null}
| | | +-[DOT] DotNode: 'DATABASE_OBJECT_DATA_ID' {propertyName=databaseObjectData,dereferenceType=2,propertyPath=databaseObjectDataMappingPK.databaseObjectData,path=dodm.databaseObjectDataMappingPK,tableAlias=databaseob0_,className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping,classAlias=dodm}
| | | | +-[ALIAS_REF] IdentNode: '(COLUMN_NAME, DATABASE_OBJECT_DATA_ID)' {alias=dodm, className=com.comp.main.service.beans.persistence.DatabaseObjectDataMapping, tableAlias=databaseob0_}
| | | | \-[IDENT] IdentNode: 'databaseObjectDataMappingPK' {originalText=databaseObjectDataMappingPK}
| | | \-[IDENT] IdentNode: 'databaseObjectData' {originalText=databaseObjectData}
| | \-[IDENT] IdentNode: 'task' {originalText=task}
| \-[IDENT] IdentNode: 'taskId' {originalText=taskId}
\-[NAMED_PARAM] ParameterNode: '?' {name=1, expectedType=org.hibernate.type.IntegerType@79a340}

17:00:11 DEBUG ErrorCounter - throwQueryException() : no errors
17:00:11 DEBUG ErrorCounter - throwQueryException() : no errors
17:00:11 DEBUG HQLQueryPlan - HQL param location recognition took 0 mills (delete DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1)
17:00:11 DEBUG QueryPlanCache - located HQL query plan in cache (delete DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1)
17:00:11 DEBUG HQLQueryPlan - executeUpdate: delete DatabaseObjectDataMapping dodm where dodm.databaseObjectDataMappingPK.databaseObjectData.task.taskId = ?1
17:00:11 DEBUG QueryParameters - named parameters: {1=304}
17:00:11 DEBUG AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
17:00:11 DEBUG SQL -
delete
from
database_object_data_mapping,
database_object_data databaseob1_
where
TASK_ID=?
Hibernate:
delete
from
database_object_data_mapping,
database_object_data databaseob1_
where
TASK_ID=?
17:00:11 DEBUG AbstractBatcher - preparing statement
17:00:11 DEBUG IntegerType - binding '304' to parameter: 1
17:00:11 DEBUG AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
17:00:11 DEBUG AbstractBatcher - closing statement
17:00:11 DEBUG JDBCExceptionReporter - could not execute update query [delete from database_object_data_mapping, database_object_data databaseob1_ where TASK_ID=?]
java.sql.SQLException: ORA-00933: SQL command not properly ended[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 04, 2008 7:01 am 
Newbie

Joined: Fri Jun 15, 2007 2:32 pm
Posts: 16
Should I post a bug on JIRA?


Top
 Profile  
 
 Post subject: questions
PostPosted: Tue May 06, 2008 7:30 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
Hi, pls clarify, maybe I'm missing something: you executed 2 queries separately - one select and one delete - and you expect Hibernate to run them as a single query?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 06, 2008 7:42 am 
Newbie

Joined: Fri Jun 15, 2007 2:32 pm
Posts: 16
No... I'm sorry if I wasn't clear.

The delete statement is the problem.

I wrote the select statement in order to show that when I execute a select statement, Hibernate knows how to create the joins needed to fetch the correct results.

When I execute a delete, Hibernate for some reason does not create the correct delete statement with joins as expected and shown above.


Top
 Profile  
 
 Post subject: I think you're right
PostPosted: Tue May 06, 2008 8:31 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
What oracle version are you using?
What dialect did you select in hibernate cfg?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 06, 2008 8:47 am 
Newbie

Joined: Fri Jun 15, 2007 2:32 pm
Posts: 16
I am using Oracle 9 and "org.hibernate.dialect.OracleDialect" as the dialect.


Top
 Profile  
 
 Post subject: oracle
PostPosted: Tue May 06, 2008 9:24 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
oracle 9i ? did u try Oracle9Dialect?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 06, 2008 10:12 am 
Newbie

Joined: Fri Jun 15, 2007 2:32 pm
Posts: 16
Yes. I also tried it.
I think that this is not the problem because the dialect is working properly in the select statement generation.


Top
 Profile  
 
 Post subject: bug
PostPosted: Tue May 06, 2008 10:26 am 
Senior
Senior

Joined: Sun Jun 11, 2006 10:41 am
Posts: 164
yeah, I'm not an official authority, but try posting a JIRA issue, or at least search the JIRA for anything similar.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.