java - Hibernate generating a query from Named Query that joins on the wrong column? -


i using named query (hibernate 4).entity defined below.

    @entity        @namedquery(         name = "findallproduct",         query = "select pc.pincode,po.description"         +" product_vendor_payment_option_location pvpol"          +" inner join pvpol.paymentid pid"          +" inner join pvpol.pincode pc"         +" inner join pvpol.paymentoptions po"         +" pvpol.id = :id"          )       public class product_vendor_payment_option_location extends baseentity.entity {          @id         @generatedvalue(strategy=generationtype.auto)         private int id;          @column(name="payment_id")         @onetomany(cascade=cascadetype.all,fetch=fetchtype.eager,mappedby="id")         private set<product_catalog_vendor> paymentid;           @column(name="pincode_id")         @onetomany(cascade=cascadetype.all,fetch=fetchtype.eager,mappedby="pincode_id")         private set<pincodes> pincode;                @column(name = "payment_options")          @onetomany(cascade=cascadetype.all,fetch=fetchtype.eager,mappedby="paymentoptions")          private set<payment_options> paymentoptions;  //protected setter getter here  } 

hibernate generating below sql:-

    select  pincode2_.pincode col_0_0_,    paymentopt3_.description col_1_0_     product_vendor_payment_option_location product_ve0_  inner join    product_catalog_vendor paymentid1_          on product_ve0_.id=paymentid1_.id  inner join    pincodes pincode2_          on product_ve0_.id=pincode2_.pincode_id  inner join    payement_options paymentopt3_          on product_ve0_.id=paymentopt3_.payment_options     product_ve0_.id=? 

instead of

select pincode2_.pincode col_0_0_,  paymentopt3_.description col_1_0_  product_vendor_payment_option_location product_ve0_ inner join product_catalog_vendor paymentid1_          on **product_ve0_.payment_id = paymentid1_.id**  inner join pincodes pincode2_          on **product_ve0_.pincode_id = pincode2_.pincode_id** inner join payement_options paymentopt3_          on **product_ve0_.payment_options=paymentopt3_.payment_options** product_ve0_.id=1; 

product_catalog_vendor class:

@entity     public class product_catalog_vendor extends baseentity.entity {              @id             @column(name="id")             private int id ;    //setters , getters here  } 

pincodes entity:

@entity public class pincodes extends baseentity.entity {        @id     private int pincode_id;      @column(name="pincode")     private int pincode;   //setters , getters here } 

payment_options entity below:

@entity @table(name="payement_options")      public class payment_options extends baseentity.entity {      @id     @column(name="payment_options")     private int paymentoptions;   //setter getter 

}

i have searched on many sites unable find cause behind scene. please give me suggestions if doing wrong. references appreciated. thanks

just problem correcty, query joins on paymentid1_.id instead of paymentid1_.id? or missing differenz between expected , real query?

i'm not pro guessing query joining id of product_catalog_vendor:

@id @column(name="id") private int id ; 

so because thats why id , not id...


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -