on 08-29-2006 8:39 AM
Hello Experts,
i am facing some probelm with copound primarykey.
the Probelm is
i have data base table which has compound primary key for that one i have created the entity bean(CMP) and primary key of type compound.using this i am able to insert record into databse but for updation i am using
<b>findbyPrimarykey()</b> method ,for that methos i am passing
primary key object with compound key values.
when i am executing this methos it is throwing <b>nosuchobject exception.</b>
what might be the problem
any help will be appriciated
thanks in advance
With Regds
Naidu
Hi Voss,
Record is already there in the database.
with Regds
Naidu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Is ur compound primarykey class is something like this?
public class PrimaryKey implements java.io.Serializable {
public String id = "";
public int no = 0;
//a default constructor is required:
public PrimaryKey() { }
// optional constructor fo clients:
public PrimaryKey(String id, int no) {
this.id = smsId;
this.no = no;
}
public String toString() {
return id + "" + no;
}
public boolean equals(Object obj) {
if (obj == null || !(obj instanceof PrimaryKey))
return false;
else if ((((PrimaryKey)obj).no == no) && (((PrimaryKey)obj).id.equals(id)))
return true;
else
return false;
}
public int hashCode() {
return id.hashCode() + no ;
}
}
Hi,
that means there is no object in the DB which matches the primary key.
Regards
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.