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.  [ 3 posts ] 
Author Message
 Post subject: Criteria Query generating SQL with (1=1)
PostPosted: Wed Nov 16, 2005 4:24 pm 
Beginner
Beginner

Joined: Wed May 25, 2005 7:49 pm
Posts: 25
When I use a Criteria query, it generates a query involving 1=1. Does anyone have a quick explanation for why it does this? If needed, I can post all the details.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 4:59 pm 
Newbie

Joined: Wed Nov 16, 2005 10:58 am
Posts: 5
I've seen this happen when there are no active conditions on the Criteria.

Specifically, I've seen it happen in Example criteria when the only attributes set on the Example class were either associations or the identifier property. Example criteria ignore both of these, and the generated query includes the "where (1=1)" condition.

If you're using Example criteria, you may want to check out the "Example Criteria" section of the "Criteria Queries" chapter of the Hibernate reference documentation. It describes how to get around this behavior for associations. A similar approach works for identifiers as well.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 16, 2005 5:04 pm 
Beginner
Beginner

Joined: Wed May 25, 2005 7:49 pm
Posts: 25
Thanks for your input, mmonette. I looked in that section, and that's actually how I am specifying associations (by using subcriteria). I am indeed using an Example, as well. I'll look more closely into which fields are being populated.


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