-->
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.  [ 12 posts ] 
Author Message
 Post subject: Performing QBE on Views
PostPosted: Thu Jan 20, 2005 10:28 pm 
Newbie

Joined: Thu Jan 20, 2005 10:16 pm
Posts: 5
Hello,

Relatively new to Hibernate, I am trying to perform a query by example on Views. However, none of the restrictions I place are converted to SQL, resulting in a WHERE (1=1) irreguardless of how many parameters I set in my example object.

I have heard that Hibernate ignores ID's while performing QBE. Is there any possibility that Hibernate is seeing the whole view row as an ID, effectively ignoring any set values?

Is there anyway to get around this, besides creating a table for each view?

Thanks for any help!

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 5:20 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Did you read the rules for this forum? They include tips on how to resolve trivial problems like this yourself.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 4:15 pm 
Newbie

Joined: Thu Jan 20, 2005 10:16 pm
Posts: 5
I’m sorry but I don’t believe this is a trivial problem.

We used middlegen to generate the mapping file which created composite ids including all the fields.
Posting http://forum.hibernate.org/viewtopic.php?t=927063 states that QBE ignores IDs (not mentioned in the documentation of QBE, BTW), so we rewrote the mapping file for the view so that there is only one field as id and the rest as properties and QBE still didn’t work.

Is there anything we are overlooking, or is there any documentation you could point us towards instead of being so vague.

Thank you,

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 4:21 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Why would you use QBE if you know the identifier value of a single instance and could use load() or get()?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 4:36 pm 
Newbie

Joined: Thu Jan 20, 2005 10:16 pm
Posts: 5
The example object uses a hibernate mapping file generated by middlegen on a VIEW. Middlegen creates a composite id of ALL fields in the view, So ANY search is a search on an ID.

Is there any way for it to form a valid where statement in this case?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 4:41 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Yes, use load() or get() with an instance of your entity class as the primary key object.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 21, 2005 7:03 pm 
Newbie

Joined: Thu Jan 20, 2005 10:16 pm
Posts: 5
I don't think you understand the problem. We are not looking for a single entity, we are looking for a list of objects.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 4:53 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And you have the primary keys of those objects, right? Use load() or get() to retrieve them.


Top
 Profile  
 
 Post subject: solution
PostPosted: Wed Jan 26, 2005 7:07 pm 
Newbie

Joined: Thu Jan 20, 2005 10:16 pm
Posts: 5
Thanks for all your help,

We determined that the problem was with the mapping files for our views-- we had all properties set as "key - properties" (a composite id) . This caused hibernate to ignore all fields for QBE because (as we learned from searching the forum) Hibernate QBE ignores ID fields. That is why we were getting where(1=1) even when setting values on our example object. We picked a field to be the ID, and set the other fields to 'property'.

You may want to make a note of the fact QBE ignores ID fields. For simple primary keys it makes sense, but composite IDs create surprises.


Top
 Profile  
 
 Post subject: Re: solution
PostPosted: Wed Jan 26, 2005 7:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
rhinman wrote:
You may want to make a note of the fact QBE ignores ID fields. For simple primary keys it makes sense, but composite IDs create surprises.


Very Good Point. This for some reason never occurred to me before.

Would you please add a JIRA issue, pointing this out. I think this is a bad limitation of our QBE.


Top
 Profile  
 
 Post subject: Re: Performing QBE on Views
PostPosted: Wed Jun 03, 2009 3:04 pm 
Newbie

Joined: Wed Jun 03, 2009 2:46 pm
Posts: 1
Has the QBE issue for querying on part of a composite key been addressed?


Top
 Profile  
 
 Post subject: Re: Performing QBE on Views
PostPosted: Tue Oct 06, 2009 1:35 am 
Regular
Regular

Joined: Tue May 12, 2009 6:08 am
Posts: 92
I just stumbled on this by googling my problem and in 3.3.2.ga this is still a problem. I tried to query by example an object with an id value and it refuses to add it the sql. I dunno if this is by design, but it's very annoying.

In my case, I want to test "a.b.c.id". The intuitive way to set this up is creating 3 criteria queries, one after the other and then on the 3rd example, we want to set id to the value I want.

Unfortunately, the framework just ignores it and there is no optional setting to tell hibernate not to do this.

As it stands, I guess qbe doesn't work in practice? I can't do anything else other than the ID - nothing else is unique.


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