-->
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: HibernateTemplate Composite Key fetching value null
PostPosted: Fri Dec 11, 2009 5:17 am 
Newbie

Joined: Fri Dec 11, 2009 5:13 am
Posts: 1
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...


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.