From: Georgios S. (JIRA) <no...@at...> - 2006-03-08 14:55:14
|
Query syntax error using IdentifierProjection.toSqlString() ----------------------------------------------------------- Key: HHH-1547 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1547 Project: Hibernate3 Type: Bug Components: query-criteria Versions: 3.1.2 Environment: Hibernate 3.1.2 Oracle Database 10g Release 1 Reporter: Georgios Skempes Priority: Minor 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: ------------------------------------------------------ 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: ------------------------------------- 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(); } } The generated SQL (show_sql=true): select address0_.PAR_ID as col_0_0_address0_.NUM as col_1_0_, ... -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |