It seems that the sql code generated from the hql update RelEmissionSociete rel set rel.emission = :a where rel.emission = :b and 0 = (select count(deja.id) from RelEmissionSociete deja where deja.societe = rel.societe and deja.role = rel.role) is malformed.
Any suggestion will be appreciated, thanks
Hibernate version: 3.1.3
Code between sessionFactory.openSession() and session.close():
Query query=getSession().createQuery( "update RelEmissionSociete rel set rel.emission = :a where rel.emission = :b and 0 = (select count(deja.id) from RelEmissionSociete deja where deja.societe = rel.societe and deja.role = rel.role)");
Emission ema=new Emission();
Emission emb=new Emission();
ema.setId(new Long(55));
emb.setId(new Long(88));
query.setEntity("a",ema);
query.setEntity("b",emb);
query.executeUpdate();
Database error:
ORA-00904: "RELEMISSIO0_"."ROLE": invalid identifier
Name and version of the database you are using:Oracle10g
The generated SQL (show_sql=true):
update REL_EMISSION_SOCIETE set EMISSION=88 where EMISSION=22 and 0=(select count(relemissio1_.ID)
from REL_EMISSION_SOCIETE relemissio1_ where relemissio1_.SOCIETE=relemissio0_.SOCIETE and relemissio1_.ROLE=relemissio0_.ROLE)
It is missing the alias name for REL_EMISSION_SOCIETE that should be relemissio0_ and then the sql generated works fine
Debug level Hibernate log excerpt:
DEBUG 11 juil. 2006 11:23:54,828 hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:68) org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
DEBUG 11 juil. 2006 11:23:54,875 hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:68) org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
DEBUG 11 juil. 2006 11:23:54,890 engine.query.HQLQueryPlan.buildParameterMetadata(HQLQueryPlan.java:219) org.hibernate.engine.query.HQLQueryPlan - HQL param location recognition took 15 mills (update RelEmissionSociete rel set rel.emission = :a where rel.emission = :b and 0 = (select count(deja.id) from RelEmissionSociete deja where deja.societe = rel.societe and deja.role = rel.role))
DEBUG 11 juil. 2006 11:23:54,906 engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:75) org.hibernate.engine.query.QueryPlanCache - located HQL query plan in cache (update RelEmissionSociete rel set rel.emission = :a where rel.emission = :b and 0 = (select count(deja.id) from RelEmissionSociete deja where deja.societe = rel.societe and deja.role = rel.role))
DEBUG 11 juil. 2006 11:23:54,906 engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:201) org.hibernate.engine.query.HQLQueryPlan - executeUpdate: update RelEmissionSociete rel set rel.emission = :a where rel.emission = :b and 0 = (select count(deja.id) from RelEmissionSociete deja where deja.societe = rel.societe and deja.role = rel.role)
DEBUG 11 juil. 2006 11:23:54,906 hibernate.engine.QueryParameters.traceParameters(QueryParameters.java:262) org.hibernate.engine.QueryParameters - named parameters: {a=com.acamaya.mediametrie.modele.Emission#88, b=com.acamaya.mediametrie.modele.Emission#null}
DEBUG 11 juil. 2006 11:23:54,906 hibernate.jdbc.AbstractBatcher.logOpenPreparedStatement(AbstractBatcher.java:311) org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG 11 juil. 2006 11:23:54,906 hibernate.jdbc.AbstractBatcher.log(AbstractBatcher.java:346) org.hibernate.SQL - update REL_EMISSION_SOCIETE set EMISSION=? where EMISSION=? and 0=(select count(relemissio1_.ID) from REL_EMISSION_SOCIETE relemissio1_ where relemissio1_.SOCIETE=relemissio0_.SOCIETE and relemissio1_.ROLE=relemissio0_.ROLE)
DEBUG 11 juil. 2006 11:23:54,906 hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:424) org.hibernate.jdbc.AbstractBatcher - preparing statement
DEBUG 11 juil. 2006 11:23:54,921 hibernate.engine.IdentifierValue.isUnsaved(IdentifierValue.java:104) org.hibernate.engine.IdentifierValue - id unsaved-value: null
DEBUG 11 juil. 2006 11:23:54,921 hibernate.type.NullableType.nullSafeSet(NullableType.java:80) org.hibernate.type.LongType - binding '88' to parameter: 1
DEBUG 11 juil. 2006 11:23:54,937 hibernate.jdbc.AbstractBatcher.logClosePreparedStatement(AbstractBatcher.java:319) org.hibernate.jdbc.AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG 11 juil. 2006 11:23:54,937 hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher.java:470) org.hibernate.jdbc.AbstractBatcher - closing statement
DEBUG 11 juil. 2006 11:23:54,984 hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:152) org.hibernate.transaction.JDBCTransaction - rollback
DEBUG 11 juil. 2006 11:23:54,984 hibernate.transaction.JDBCTransaction.rollback(JDBCTransaction.java:163) org.hibernate.transaction.JDBCTransaction - rolled back JDBC Connection
DEBUG 11 juil. 2006 11:23:54,984 hibernate.jdbc.JDBCContext.afterTransactionCompletion(JDBCContext.java:199) org.hibernate.jdbc.JDBCContext - after transaction completion
DEBUG 11 juil. 2006 11:23:55,000 hibernate.jdbc.ConnectionManager.aggressiveRelease(ConnectionManager.java:398) org.hibernate.jdbc.ConnectionManager - aggressively releasing JDBC connection
DEBUG 11 juil. 2006 11:23:55,000 hibernate.jdbc.ConnectionManager.closeConnection(ConnectionManager.java:435) org.hibernate.jdbc.ConnectionManager - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
DEBUG 11 juil. 2006 11:23:55,000 hibernate.impl.SessionImpl.afterTransactionCompletion(SessionImpl.java:417) org.hibernate.impl.SessionImpl - after transaction completion
DEBUG 11 juil. 2006 11:23:55,015 hibernate.impl.SessionImpl.close(SessionImpl.java:268) org.hibernate.impl.SessionImpl - closing session
DEBUG 11 juil. 2006 11:23:55,015 hibernate.jdbc.ConnectionManager.cleanup(ConnectionManager.java:369) org.hibernate.jdbc.ConnectionManager - connection already null in cleanup : no action
Last edited by patomareado on Thu Jul 13, 2006 9:47 am, edited 1 time in total.
|