Hi,
I have 2 tables, here is the structrure.
@Table(name = "TXN") public class Transaction implements Serializable { private static final long serialVersionUID = 1L;
@Id @Column(name = "TH_ID") private Long iId; @Column(name = "TH_CHARGE_MODEL_ID", unique = false, nullable = true, updatable = true, length = 40) private Integer iChargeModelId; @OneToMany(cascade = CascadeType.ALL,fetch=FetchType.EAGER) @JoinColumn(name="chargeModelId") private List<SoftDescriptorEntity> sdList; }
@Entity @Table(name = "SOFTDESCRIPTORS") public class SoftDescriptorEntity implements Serializable { private static final long serialVersionUID = 1L;
@Id @Column(name = "SD_ID") public Long id;
@Column(name = "SD_CHARGE_MODEL_ID", insertable = false, unique = false, nullable = false, updatable = false) public Integer chargeModelId; @Column(name = "SD_VALUE", insertable = false, unique = false, nullable = false, updatable = false) public String value;
} I want to fetch all the records from TXN table that match the chargeModelId from the SOFTDESCRIPTORS.
Thus I have used @JoinColumn(name="chargeModelId") in the Transaction class.
But when I run the application I am getting the following query when I am doing the criteria to select all the records from TXN table.
Select ...... from ... where .... left outer join SOFT_DESCRIPTORS sdlist4_ on th1_.TH_ID=sdlist4_.SD_ID
This is not what I want. I want hibernate to compare TH_CHARGE_MODEL_ID and SD_CHARGE_MODEL_ID instead.
Kindly let me know if I am doing anything wrong in the @JoinColumn or anything I am missing.
|