Hi all,
I have one primary table and one secondary table.
The table structure as follows :
TableA (primary table)
TableB (secondary table)
TableA (ID, column1,column2,colum3)
TableB(ID,column4,column5,column6)
The TabelA.hbm.xml structure as follows
Quote:
<class name="com.gpt.NewAccount" table="TABLEA">
<cache usage="read-write"/>
<id name="id" type="java.lang.String" column="ID">
<generator class="assigned" />
</id>
</property>
<property
name="column1"
type="java.lang.String"
column="COLUMN1"
length="60"
lazy="true"
/>
<property
name="column2"
type="java.lang.String"
column="COLUMN2"
length="60"
lazy="true"
/>
<property
name="column3"
type="java.lang.String"
column="COLUMN3"
length="60"
lazy="true"
/>
<join table="TABLEB" fetch="select" optional="true">
<key>
<column name="ID"></column>
</key>
<property
name="column4"
type="java.lang.String"
column="COLUMN4"
length="60"
lazy="true"
/>
<property
name="column5"
type="java.lang.String"
column="COLUMN5"
length="60"
lazy="true"
/>
<property
name="column6"
type="java.lang.String"
column="COLUMN6"
length="60"
lazy="true"
/>
</join>
</class>
I am firing a Query like this
Quote:
Update TABLEA set column1="abcd" where ID = '123'
Hibernate parse the above query like this
Quote:
insert into HT_TABLEA select tablea0_.CS_ID as CS_ID from TABLEA tablea0_, TABLEB tablea0_1_ where tablea0_.ID=tablea0_1_.ID(+) and ID=?
I am not able to understand why hibernate add
"HT" keyword in front of Table name.
Hibernate throws the following exception.
Quote:
Hibernate: delete from HT_TABLEA
org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert/select ids for bulk update; nested exception is org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:615)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:379)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls$5.doInTransaction(HibernateDatabaseCalls.java:300)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls.executeHqlUpdate(HibernateDatabaseCalls.java:294)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls.main(HibernateDatabaseCalls.java:4698)
Caused by: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:92)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.executeUpdate(QueryTranslatorImpl.java:421)
at org.hibernate.engine.query.HQLQueryPlan.performExecuteUpdate(HQLQueryPlan.java:283)
at org.hibernate.impl.SessionImpl.executeUpdate(SessionImpl.java:1288)
at org.hibernate.impl.QueryImpl.executeUpdate(QueryImpl.java:117)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls$5$1.doInHibernate(HibernateDatabaseCalls.java:307)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:374)
... 5 more
Caused by: java.sql.SQLException: ORA-00918: column ambiguously defined
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:219)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:970)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3454)
at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:142)
... 11 more
Exception in thread "main" com.capgent.cpt.service.database.exceptions.HibernateDatabaseException: could not insert/select ids for bulk update; nested exception is org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update,
caused by could not insert/select ids for bulk update; nested exception is org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls.executeHqlUpdate(HibernateDatabaseCalls.java:316)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls.main(HibernateDatabaseCalls.java:4698)
Caused by: org.springframework.dao.InvalidDataAccessResourceUsageException: could not insert/select ids for bulk update; nested exception is org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update
at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:615)
at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:379)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls$5.doInTransaction(HibernateDatabaseCalls.java:300)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:128)
at com.capgent.cpt.service.database.utils.HibernateDatabaseCalls.executeHqlUpdate(HibernateDatabaseCalls.java:294)
Thanks,
Ganesh Shirsat