MainTable.java extends Common.java private Long id ; private Long version ; private String name ; private SubTable sub ; SubTable.java extends Common.java private String subname ; prviate String dualname ; Common.java private Long id ; prviate Date createDate ; HQL v String sql = "update MainTable set name = ? where sub.id = ? and version = ?" ; Query query = session..createQuery(sql); // set paramerts query.executeUpdate();
Hibernate Generated SQL
update MainTable set name =? where templateve0_.SUB_ID=? and version =?
Error
ERROR org.hibernate.util.JDBCExceptionReporter – ORA-00904: “TEMPLATEVE0_”.”SUB_ID”: invalid identifier
FYI – SUB_ID is a valid column name.
I am not sure why is hibernate adding templateve0_ alias only for the sub-object. Any help?
Original –
String sql = “update MainTable set name = ? where sub.id = ? and version = ?” ;
Updated
String sql = “update MainTable set name = ? where SUB_ID = ? and version = ?” ;
I replaced sub.id with the actual column name and it seems to be working! Very Strange!