From: Max M. (JIRA) <no...@at...> - 2005-10-25 08:09:16
|
IdentifierProjection does not work with composite keys ------------------------------------------------------ Key: HHH-1088 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088 Project: Hibernate3 Type: Bug Versions: 3.1 rc2 Reporter: Max Muermann Priority: Minor When working with Criteria queries, the IdentifierProjection breaks if the entity has a composite key. In IdentifierProjection.java: 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(); } This method does not add commas as separators between the column names. Easily fixed by adding if (i<col.length-1) buf.append(","); as the last statement inside the loop. However, this leads to another problem: the type returned by IdentifierProjection.geType is the (single) type of the composite id component. The query will however return the property values of the id component without a mapping step. -- 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 |
From: Gavin K. (JIRA) <no...@at...> - 2005-10-26 21:03:12
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088?page=comments#action_20464 ] Gavin King commented on HHH-1088: --------------------------------- I don't see how projections make sense for composite types. I would rather throw an explicit exception. > IdentifierProjection does not work with composite keys > ------------------------------------------------------ > > Key: HHH-1088 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088 > Project: Hibernate3 > Type: Bug > Versions: 3.1 rc2 > Reporter: Max Muermann > Priority: Minor > > > When working with Criteria queries, the IdentifierProjection breaks if the entity has a composite key. > In IdentifierProjection.java: > 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(); > } > This method does not add commas as separators between the column names. Easily fixed by adding > if (i<col.length-1) > buf.append(","); > as the last statement inside the loop. > However, this leads to another problem: > the type returned by IdentifierProjection.geType is the (single) type of the composite id component. The query will however return the property values of the id component without a mapping step. -- 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 |
From: Max M. (JIRA) <no...@at...> - 2005-10-26 22:17:12
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088?page=comments#action_20481 ] Max Muermann commented on HHH-1088: ----------------------------------- I believe it does make sense when combined with the distinct projection. In any case, the behaviour should be defined. > IdentifierProjection does not work with composite keys > ------------------------------------------------------ > > Key: HHH-1088 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088 > Project: Hibernate3 > Type: Bug > Versions: 3.1 rc2 > Reporter: Max Muermann > Priority: Minor > > > When working with Criteria queries, the IdentifierProjection breaks if the entity has a composite key. > In IdentifierProjection.java: > 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(); > } > This method does not add commas as separators between the column names. Easily fixed by adding > if (i<col.length-1) > buf.append(","); > as the last statement inside the loop. > However, this leads to another problem: > the type returned by IdentifierProjection.geType is the (single) type of the composite id component. The query will however return the property values of the id component without a mapping step. -- 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 |
From: Viatcheslav (JIRA) <no...@at...> - 2006-05-11 10:07:15
|
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088?page=comments#action_23078 ] Viatcheslav commented on HHH-1088: ---------------------------------- HH-1547is the same reported. I'd raise the priority of the bug because of many users affected. > IdentifierProjection does not work with composite keys > ------------------------------------------------------ > > Key: HHH-1088 > URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-1088 > Project: Hibernate3 > Type: Bug > Versions: 3.1 rc2 > Reporter: Max Muermann > Priority: Minor > > > When working with Criteria queries, the IdentifierProjection breaks if the entity has a composite key. > In IdentifierProjection.java: > 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(); > } > This method does not add commas as separators between the column names. Easily fixed by adding > if (i<col.length-1) > buf.append(","); > as the last statement inside the loop. > However, this leads to another problem: > the type returned by IdentifierProjection.geType is the (single) type of the composite id component. The query will however return the property values of the id component without a mapping step. -- 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 |