-->
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: Problem with setResultTransformer and composite-id
PostPosted: Fri Aug 27, 2010 10:41 am 
Newbie

Joined: Fri Aug 27, 2010 10:24 am
Posts: 1
I have a complex problem on my hands.

I am trying to do a select of 4 fields out of 16 in my object with criteria. It wasn't working until I used
setResultTransformer(Transformers.aliasToBean(Clazz.class)).

I am trying to do the exact same thing but selecting fields of a composite-id : id.field1, id.field2, id.field3 and field4.
Here is the criteria code:

Code:
criteria = session.createCriteria(Clazz.class);
        ProjectionList projList = Projections.projectionList();
        projList.add(Projections.property("id.field1"), "id.field1");
        projList.add(Projections.property("id.field2"), "id.field2");
        projList.add(Projections.property("id.field3"), "id.field3");
        projList.add(Projections.property("field4"), "field4");
        criteria.setProjection(projList);
        criteria.add(Restrictions.eq("id.field1", field1));
        criteria.add(Restrictions.eq("id.field2", field2));Clazz.class));


It generates this SQL:
Code:
select this_.FIELD1 as y0_, this_.FIELD2 as y1_, this_.FIELD3 as y2_, this_.FIELD4 as y3_ from Table1 this_ where y1_=? and y0_=?

Fields 1, 2 and 3 are in the class ClazzId and field 4 is in Clazz. I mapped a composite-id with these 3 fields.

I get an error of this type:

Code:
junit.framework.AssertionFailedError: error in getFields: org.hibernate.exception.SQLGrammarException: could not execute query



Can someone tell me what I did wrong and what can I do to resolve it?


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.