Hi Chandu,
Create a Primary Key class with all the fields that it constitutes. The class must implement the serializable interface and the methods in java.lang.Object interface. It must contain an empty constructor too.
Example :
import java.io.Serializable;
public class AdvancedReportingPK implements Serializable {
public Long sequenceNumber;
public
String hostName;
public AdvancedReportingPK(Long sequenceNumber, String hostName) {
this.sequenceNumber = sequenceNumber;
this.hostName = hostName;
}
public AdvancedReportingPK() {
}
public String toString() {
return sequenceNumber.toString() + hostName;
}
public int hashCode() {
return sequenceNumber.hashCode();
}
public boolean equals(Object log) {
return ((AdvancedReportingPK) log).sequenceNumber
.equals(sequenceNumber)
&& ((AdvancedReportingPK) log).hostName.equals(hostName);
}
}
Later you have to add the entry of this primary key class in your ejb-jar.xml in the following way:
<entity>
<display-name>AEJB</display-name>
<ejb-name>A</ejb-name>
<local-home>AHome</local-home>
<local>A</local>
<ejb-class>ABean</ejb-class>
<persistence-type>Container</persistence-type>
<prim-key-class>AdvancedReportingPK</prim-key-class>
<reentrant>False</reentrant>
<cmp-version>2.x</cmp-version>
<abstract-schema-name>A</abstract-schema-name>
<cmp-field>
<field-name>sequenceNumber</field-name>
</cmp-field>
<cmp-field>
<field-name>hostName</field-name>
</cmp-field>
<cmp-field>
<field-name>originationTime</field-name>
</cmp-field>
<cmp-field>
<field-name>QID</field-name>
</cmp-field>
</entity>
Hope this helps you.
Thanks
Kala Praveen