-->
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.  [ 2 posts ] 
Author Message
 Post subject: Does projections aliases work with Derby?
PostPosted: Tue Mar 29, 2011 12:54 pm 
Newbie

Joined: Tue Mar 29, 2011 12:26 pm
Posts: 2
Hi,

I'm using Hibernate 3.3.0.SP1 and Derby 10.6.1.0

I try to build a Criteria via the Hibernate Criteria API. To narrow the resultset I use projections. I need to set the aliases the get the targetclass injected.
Code:
ProjectionList projectionList = Projections.projectionList();

projectionList.add(Projections.distinct(Projections.property(ATTR_ID)), ATTR_ID);
projectionList.add(Projections.property(ATTR_UMBRELLA_ID), ATTR_UMBRELLA_ID);
projectionList.add(Projections.property(ATTR_UMBRELLA_NAME), ATTR_UMBRELLA_NAME);
criteria.setProjection(projectionList);
criteria.setResultTransformer(Transformers.aliasToBean(UmbrellaFonds.class));


But unfortunately I get an error on the following created statement:
Code:
select distinct this_.UMBRELLA_FONDS_OID as y0_, this_.UMBRELLA_ID as y1_, this_.umbrellaname as y2_ from V_UMBRELLA_FONDS this_ where y1_=?

V_UMBRELLA_FONDS is a view and UMBRELLA_ID a part of the view. Not that complicated.

Code:
Caused by: ERROR 42X04: Column 'Y1_' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE  statement then 'Y1_' is not a column in the target table.
   at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
   at org.apache.derby.impl.sql.compile.ColumnReference.bindExpression(Unknown Source)
   at org.apache.derby.impl.sql.compile.BinaryOperatorNode.bindExpression(Unknown Source)
   at org.apache.derby.impl.sql.compile.BinaryComparisonOperatorNode.bindExpression(Unknown Source)
   at org.apache.derby.impl.sql.compile.SelectNode.bindExpressions(Unknown Source)
   at org.apache.derby.impl.sql.compile.DMLStatementNode.bindExpressions(Unknown Source)
   at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
   at org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
   at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
   at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown Source)
   at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown Source)
   ... 65 more


If I execute following statement by hand everything works fine.
Code:
select distinct this_.UMBRELLA_FONDS_OID as y0_, this_.UMBRELLA_ID as y1_, this_.umbrellaname as y2_ from V_UMBRELLA_FONDS this_ where this_.UMBRELLA_ID=?


Does Derby support restrictions on projection aliases generally or is simply my comprehension on how projections work wrong?

Thanks

z-boy


Top
 Profile  
 
 Post subject: Re: Does projections aliases work with Derby?
PostPosted: Wed Mar 30, 2011 5:09 am 
Newbie

Joined: Tue Mar 29, 2011 12:26 pm
Posts: 2
Obviously a known Hibernate bug, which should be fixed in 3.6.0

http://opensource.atlassian.com/projects/hibernate/browse/HHH-817


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

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.