-->
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.  [ 7 posts ] 
Author Message
 Post subject: how to set alias for example criterion
PostPosted: Fri Feb 29, 2008 10:08 am 
Newbie

Joined: Fri Feb 29, 2008 9:32 am
Posts: 2
Hibernate version:3.2.5
Name and version of the database:Oracle 10g

Hi all
I have problem with examples:

This code doesn't work:
(...)
Example indvExample=Example.create(params.getIndividuals());
Criteria criteria = getSession().createCriteria(Individuals.class, "indv")
.add(indvExample);
(... projections and some other stuff ...)

error:
JDBCExceptionReporter:77 - SQL Error: 904, SQLState: 42000
JDBCExceptionReporter:78 - ORA-00904: "Y7_": invalid identifier

sql:
select * from ( select <many colums>,this_."INDV_PASSPORT_NUMBER" as y7_ from "INDIVIDUALS" this_, <other tables> where <some other stuff> and (y7_=?) )

problem is with (y7_=?)

when i use this code:
Criteria criteria = getSession().createCriteria(Individuals.class, "indv")
.add( Restrictions.eq("indv.indvPassportNumber", "nf a2+QvDL8"));

all is ok and sql looks like that:
select * from ( select <many colums>,this_."INDV_PASSPORT_NUMBER" as y7_ from "INDIVIDUALS" this_, <other tables> where this_."INDV_PASSPORT_NUMBER"=? )

when i use this:
Criteria criteria = getSession().createCriteria(Individuals.class, "indv")
.add( Restrictions.eq("<no alias>indvPassportNumber", "nf a2+QvDL8"));

I get the same error like withe exaples ("Y7_": invalid identifier) and sql look the same ((y7_=?) insted of this_."INDV_PASSPORT_NUMBER"=?).

Sow the only different is alias i can set with Restrictions and can't with Example. My question is: how to set alias for example or how to add example in the way that it knows what alias should it use?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 29, 2008 4:56 pm 
Beginner
Beginner

Joined: Tue Aug 16, 2005 3:44 pm
Posts: 33
Hi!

This might be a shot in the dark... but you might take a look at http://opensource.atlassian.com/projects/hibernate/browse/HHH-1685 incase that issue in some way could be related to your issue.

If it is, the good news is that it is fixed in hibernate 3.2.6 :)


-Kaj :)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 02, 2008 6:56 am 
Newbie

Joined: Fri Feb 29, 2008 9:32 am
Posts: 2
well its sound similarly but I don't think its related problem. I'm afraid examples just don't have support for alias :/ I don't know why.I think alias added to property names in Example.toSqlString should do it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 9:06 am 
Newbie

Joined: Tue Mar 08, 2005 4:57 am
Posts: 8
Hibernate version:3.2.6
Name and version of the database:Oracle 10g

I'm getting the same error and have the same query setup, i.e., some restrictions followed by some projections.

I've narrowed down the problem to occurring when a field is present in both the projections and the restrictions. Removing the field from either makes it work.

Example 1.

Restrict on foo
Project on foo

Causes the error above

Example 2

Restrict on field other than foo
Project on foo

Works ok

Example 3

Do not restrict on foo
Project on foo

Works ok.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 19, 2008 9:07 am 
Newbie

Joined: Tue Mar 08, 2005 4:57 am
Posts: 8
Double post. Deleted.


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 12, 2008 11:39 am 
Newbie

Joined: Mon May 12, 2008 11:35 am
Posts: 1
I'm seeing this same problem. Hibernate 3.2.6, Oracle 10g.

Is there a JIRA issue filed about this?


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 14, 2008 5:19 am 
Newbie

Joined: Tue Mar 08, 2005 4:57 am
Posts: 8
It seems to be a bug. I got around it by giving the restriction and the projection a different name, i.e., before I restricted on xyz and projected on xyz but I changed my projection to be abc, and it seemed to work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.