-->
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: 1=2 constraint Criteria
PostPosted: Wed Sep 08, 2010 8:37 am 
Newbie

Joined: Wed Sep 08, 2010 8:20 am
Posts: 2
I have the following code:
Code:
public List<RequestParameter> getAll(Long pendingRequestId) {
      return (List<RequestParameter>) sessionFactory.getCurrentSession()
         .createCriteria(RequestParameter.class).add(
            Property.forName("pendingRequest.id").eq(pendingRequestId))
         .list();
   }

Below is the mapping class for RequestParameter:
Code:
package com.destiny.soap.beans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.ForceDiscriminator;

@Entity
@Table(name = "soapRequestParameter")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "type")
@ForceDiscriminator
public abstract class RequestParameter
      implements Serializable {

   private static final long serialVersionUID = 634271628568734918L;

   private Long id;

   private MessageParameter messageParameter;

   private PendingRequest pendingRequest;

   public void setId(Long id) {
      this.id = id;
   }

   @Id
   @GeneratedValue(strategy = GenerationType.AUTO)
   @Column(name = "soapRequestParameter_key")
   public Long getId() {
      return id;
   }

   public void setMessageParameter(MessageParameter messageParameter) {
      this.messageParameter = messageParameter;
   }

   @ManyToOne
   @JoinColumn(name = "soapMessageParameter_fkey", nullable = false)
   public MessageParameter getMessageParameter() {
      return messageParameter;
   }

   public void setPendingRequest(PendingRequest pendingRequest) {
      this.pendingRequest = pendingRequest;
   }

   @ManyToOne
   @JoinColumn(name = "soapPendingRequest_fkey")
   public PendingRequest getPendingRequest() {
      return pendingRequest;
   }
}

Can any one help me figure out why I am getting the 1=2 constraint in my query when I run a test:
Code:
select
        this_.soapRequestParameter_key as soapRequ2_8_7_,
        this_.soapMessageParameter_fkey as soapMess3_8_7_,
        this_.soapPendingRequest_fkey as soapPend4_8_7_,
        messagepar2_.soapMessageParameter_key as soapMess2_4_0_,
        messagepar2_.soapMessageTemplate_fkey as soapMess5_4_0_,
        messagepar2_.name as name4_0_,
        messagepar2_.data as data4_0_,
        messagepar2_.type as type4_0_,
        messagetem3_.soapMessageTemplate_key as soapMess1_6_1_,
        messagetem3_.soapConfiguration_fkey as soapConf5_6_1_,
        messagetem3_.name as name6_1_,
        messagetem3_.template as template6_1_,
        messagetem3_.uri as uri6_1_,
        configurat4_.soapConfiguration_key as soapConf1_1_2_,
        configurat4_.application_fkey as applicat7_1_2_,
        configurat4_.email as email1_2_,
        configurat4_.enable as enable1_2_,
        configurat4_.password as password1_2_,
        configurat4_.url as url1_2_,
        configurat4_.username as username1_2_,
        applicatio5_.application_key as applicat1_0_3_,
        applicatio5_.appID as appID0_3_,
        applicatio5_.name as name0_3_,
        applicatio5_.status as status0_3_,
        pendingreq6_.soapPendingRequest_key as soapPend1_7_4_,
        pendingreq6_.soapConfiguration_fkey as soapConf7_7_4_,
        pendingreq6_.created as created7_4_,
        pendingreq6_.delivered as delivered7_4_,
        pendingreq6_.error as error7_4_,
        pendingreq6_.form_fkey as form8_7_4_,
        pendingreq6_.locked as locked7_4_,
        pendingreq6_.success as success7_4_,
        configurat7_.soapConfiguration_key as soapConf1_1_5_,
        configurat7_.application_fkey as applicat7_1_5_,
        configurat7_.email as email1_5_,
        configurat7_.enable as enable1_5_,
        configurat7_.password as password1_5_,
        configurat7_.url as url1_5_,
        configurat7_.username as username1_5_,
        form8_.form_key as form1_3_6_,
        form8_.sentMessage as sentMess2_3_6_
    from
        soapRequestParameter this_
    inner join
        soapMessageParameter messagepar2_
            on this_.soapMessageParameter_fkey=messagepar2_.soapMessageParameter_key
    left outer join
        soapMessageTemplate messagetem3_
            on messagepar2_.soapMessageTemplate_fkey=messagetem3_.soapMessageTemplate_key
    left outer join
        soapConfiguration configurat4_
            on messagetem3_.soapConfiguration_fkey=configurat4_.soapConfiguration_key
    left outer join
        application applicatio5_
            on configurat4_.application_fkey=applicatio5_.application_key
    left outer join
        soapPendingRequest pendingreq6_
            on this_.soapPendingRequest_fkey=pendingreq6_.soapPendingRequest_key
    left outer join
        soapConfiguration configurat7_
            on pendingreq6_.soapConfiguration_fkey=configurat7_.soapConfiguration_key
    left outer join
        form form8_
            on pendingreq6_.form_fkey=form8_.form_key
    where
        1=2
        and this_.soapPendingRequest_fkey=?


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.