Hi, I have following query in my code:
Code:
String queryString = "INSERT INTO Regg (index, code) "
+ "SELECT ( SELECT cast(count(*) - 1 as int) "
+ " FROM Code c2 "
+ " WHERE c2.parent.id = c1.parent.id AND c2.id <= c1.id), c1.code "
+ "FROM Code c1 "
+ "WHERE c1.parent.id = :DIM_ID";
Query q = session.createQuery(queryString);
q.setParameter(DIM_ID, dimId, Hibernate.LONG);
q.executeUpdate();
When query is executed I've got following trace:
Code:
insert into REG_G ( C_SEQ, C_VALUE )
select (
select cast(count(*)-1 as int)
from REG_CODE code1_
where code1_.C_DIM_ID=REG_CODE.C_DIM_ID and code1_.C_ID<=REG_CODE.C_ID) as col_0_0_,
code0_.C_CODE as col_1_0_
from REG_CODE code0_
where code0_.C_DIM_ID=?
Does anybody know why c1 is not dereferenced to code0_ and there is REG_CODE.C_ID and REG_CODE.C_DIM_ID instead of code0_.C_ID and code0_.C_DIM_ID in my internal query? Of course because of this error I've got an exception:
Code:
15:17:16,007 WARN [JDBCExceptionReporter] SQL Error: 4104, SQLState: S1000
15:17:16,007 ERROR [JDBCExceptionReporter] The multi-part identifier "REG_CODE.C_DIM_ID" could not be bound.
15:17:16,007 WARN [JDBCExceptionReporter] SQL Error: 4104, SQLState: S1000
15:17:16,007 ERROR [JDBCExceptionReporter] The multi-part identifier "REG_CODE.C_ID" could not be bound.
Is this a bug in hibernate or am I doing something wrong?
Thanks for help,
morhen