-->
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: Disjunction and Example combo gives 1=1 in where clause
PostPosted: Wed Sep 26, 2007 11:47 am 
Newbie

Joined: Wed Sep 26, 2007 11:05 am
Posts: 1
Fixed it. I'm dumb. A copy-paste problem caused me to be using the wrong class when I called getCurrentSession().createCriteria(). It's still odd that Hibernate decided to give me 1=1, but maybe it makes sense in some weird way.

I'm using Hibernate 3.2.4.sp1, and when I try to add an Example object to my Disjunction, it results in a (1=1) in my where clause. My code is basically this:

Code:
  Junction disjunction = Restrictions.disjunction();
  for (int i = 0; i < certs.length; i++) {
    disjunction.add(Example.create(certs[i]));
  }
  List results = criteria.add(disjunction).list();


In my current test, my certs array has 3 elements, and when I execute it Hibernate generates the following where clause:

Code:
   where ((1=1) or (1=1) or (1=1))


It works fine if I populate my disjunction with an individual field instead:

Code:
  disjunction.add(Expression.eq(FIELD_CERTIFICATE_NUMBER, certs[i].getCertificateNumber()));


I dug through forums, documentation, and the debug logs, but haven't been enlighted yet as to why it's behaving this way. So (1) should I be able to add an Example object to a disjunction and if so (2) how do I fix it?

Thanks for the help,


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.