-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Query syntax error using IdentifierProjection.toSqlString()
PostPosted: Thu Mar 02, 2006 3:59 am 
Beginner
Beginner

Joined: Mon Nov 22, 2004 11:21 am
Posts: 42
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

_________________
Real programmers confuse Halloween and Christmas because OCT 31 = DEC 25


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.