-->
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: criteria.setProjection can cause "column not exist" problems
PostPosted: Wed Mar 10, 2010 5:29 pm 
Newbie

Joined: Wed Mar 10, 2010 4:33 pm
Posts: 1
If there is a table "Entity" and you want to return only the name and ID fields(criteria.setProjection(<name> <id> fields) but ID is in a condition in search criteria ( Restrictions.eq("id", XXXXXX )) then hibernate generates this criteria:
select this_.NAME as y0_, this_.ID as y1_ from Entity this_ where y1_=?

Either removing the search condition(restrictions) or removing from the project fields(i.e no result) can fix this problem since the column alias(y1_) show up only if a field exists in both places.

Postgres complains the y1_ column doesn't exist. According to some people's comments on postgres, the select statement is not processed before where statement is processed so the column alias is not known in where statement. This might conform to some SQL standard.

Is this a hibrenate library issue?


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.