I am using InheritanceType.Joined in one of my project.
But when i am trying to update the data using HQL query it gives error that
Quote:
could not insert/select ids for bulk update
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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
Caused by: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
at org.hibernate.hql.ast.exec.MultiTableUpdateExecutor.execute(MultiTableUpdateExecutor.java:142)
... 48 more
Below was the hibernate SQL Log Quote:
Hibernate: /* insert-select for com.test.entity.B ids */
insert into HT_B select b.AKEY as AKEY
from TEST.B b inner join TEST.A a on b.AKEY=a.AKEY where name123=?
Below i give the sample program which i used in my projectClass A
Code:
@Entity
@Table(name = "A", schema="TEST")
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "ATYPEKEY", discriminatorType = DiscriminatorType.INTEGER, length = 1)
public abstract class A {
@Id
@Column(name = "AKEY", nullable = false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="A_SEQ")
@SequenceGenerator(name="A_SEQ", sequenceName="TEST.SEQ1_A", allocationSize=1)
private Integer aKey;
@Column(name="NAME")
private String name;
@Column(name = "XYZ")
private String xyz;
|
|
|
etc.
}
Class B
Code:
@Entity
@Table(name = "B", schema="TEST")
@DiscriminatorValue(value = "3")
public class B extends A{
@Column(name = "NAME123")
private String name123;
@Column(name = "XYZ123")
private String xyz123;
@JoinColumn(name = "CKEY", referencedColumnName = "CKEY")
@ManyToOne
private C c;
|
|
|
etc.
}
Class C
Code:
@Entity
@Table(name = "C", schema="TEST")
public class C {
@Id
@Column(name = "CKEY", nullable = false)
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="C_SEQ")
@SequenceGenerator(name="C_SEQ", sequenceName="TEST.SEQ1_C", allocationSize=1)
private Integer cKey;
@Column(name = "OPQ")
private String opq;
|
|
|
etc.
}
For updating Class B value i used below query.
Code:
String hql = "update B t0 set t0.c = (select t1 from C t1 where t1.opq = 'ANY') " +
"where t0.name123 =:name123";
Query query = getSession().createQuery(hql);
query.setString("name123", "AnyThing");
return query.executeUpdate();
Can any one have any idea about this error?