Hibernate version: 3.1.2
Name and version of the database you are using: Oracle 10g 10.1.2
The generated SQL (show_sql=true):
select address0_.PAR_ID as col_0_0_address0_.NUM as col_1_0_, ...
Hi,
while using IdentifierProjection.toSqlString() with a composite id, I got above wrong SQL syntax because of a bug. I modified the source of hibernate as follows:
Original:
Code:
package org.hibernate.criterion;
...
public class IdentifierProjection extends SimpleProjection {
...
public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer();
String[] cols = criteriaQuery.getIdentifierColumns(criteria);
for ( int i=0; i<cols.length; i++ ) {
buf.append( cols[i] )
.append(" as y")
.append(position + i)
.append("_");
}
return buf.toString();
}
}
My Modification:Code:
package org.hibernate.criterion;
...
public class IdentifierProjection extends SimpleProjection {
...
public String toSqlString(Criteria criteria, int position, CriteriaQuery criteriaQuery)
throws HibernateException {
StringBuffer buf = new StringBuffer();
String[] cols = criteriaQuery.getIdentifierColumns(criteria);
for ( int i=0; i<cols.length; i++ ) {
buf.append( cols[i] )
.append(" as y")
.append(position + i)
.append("_, ");
}
buf.delete(buf.length() - 2, buf.length());
return buf.toString();
}
}
Before reporting this as a bug I want to get a confirmation.
Regards,
Georg