cancel
Showing results for 
Search instead for 
Did you mean: 

problem With Compound Primary Key

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Voss,

Record is already there in the database.

with Regds

Naidu

Former Member
0 Kudos

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 ;

}

}

Former Member
0 Kudos

Hi,

that means there is no object in the DB which matches the primary key.

Regards

Sebastian