I have one table that has composite key 'rid' and 'sid'.
For that i have made following beans to map with hibernate annotations :
Code:
WBList.java
============
@Entity
@IdClass(WBListPK.class)
public class WBList {
private int rid;
private int sid;
private String wb;
@Id
@JoinColumn(name="rid")
public int getRid() {
return rid;
}
public void setRid(int rid) {
this.rid = rid;
}
@Id
@JoinColumn(name="sid")
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
@Column(name="wb")
public String getWb() {
return wb;
}
public void setWb(String wb) {
this.wb = wb;
}
}
WBListPK.java has following code :
@Embeddable
public class WBListPK implements Serializable {
private int rid;
private int sid;
private String wb;
public int getRid() {
return rid;
}
public void setRid(int rid) {
this.rid = rid;
}
public int getSid() {
return sid;
}
public void setSid(int sid) {
this.sid = sid;
}
public String getWb() {
return wb;
}
public void setWb(String wb) {
this.wb = wb;
}
}
My WBListDao has following method :
Code:
//Some other code ...
public WBList getWBListById(WBListPK wbListPK) {
return (WBList) this.hibernateTemplate.get(WBList.class,wbListPK);
}
Following is my controller code :
Code:
WBList wbList = new WBList();
WBListPK wbListPK = new WBListPK();
wbListPK.setRid(1);
wbListPK.setSid(7);
wbList = this.wbListSecurityProcessor.getWBListById(wbListPK);
System.out.println("Wblist = "+wbList);
When I am executing above code, the wbList fetching the null value..
If anybody have any solutions, plz help..
Thanks in advance...