aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB PK class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB PK class" Watch "EJB PK class" New topic
Author

EJB PK class

Paulo Aquino
Ranch Hand

Joined: Apr 29, 2002
Posts: 200
hello guys! i hope you can help me.If by any chance, do you have an example code on how to implement the PK class of an Entity Bean wherein the primary keys are two or more...TIA!


Be Afraid...Be very Afraid...
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
PK Class


Rick Hightower is CTO of Mammatus which focuses on Cloud Computing, EC2, etc. Rick is invovled in Java CDI and Java EE as well. linkedin,twitter,blog
Rick Hightower
Author
Ranch Hand

Joined: Feb 20, 2002
Posts: 350
Suresh Selvaraj
Ranch Hand

Joined: Nov 14, 2000
Posts: 104
Hi,
I 've written a sample code for you to see.
****** START ******
package com.sselvar;
// Import Statements
import java.io.Serializable;
public class TestEntityPK implements Serializable
{

public long personalDetailsId;
public long employeeId;

public int hashCode()
{
StringBuffer sb = new StringBuffer();
sb.append(personalDetailsId);
sb.append(employeeId);
String str=sb.toString();
return str.hashCode();
}

public boolean equals()
{
return true;
}

public java.lang.String toString()
{
return null;
}

public TestEntityPK()
{
}
public TestEntityPK (long personalDetailsId,long employeeId)
{
this.personalDetailsId=personalDetailsId;
this.employeeId=employeeId;
}
public long getPersonalDetailsId()
{
return personalDetailsId;
}
public long getEmployeeId()
{
return employeeId;
}

public boolean equals(Object obj)
{
if( (((TestEntityPK)obj).personalDetailsId==personalDetailsId) &&
(((TestEntityPK)obj).employeeId==employeeId) )
{
return true;
}
return false;
}
}
******* END *******
Regards,
Suresh Selvaraj
Sun Certified Java Programmer


Suresh Selvaraj, (author of JQuiz)<br />SCJP2<br /><a href="http://www.decontconsulting.com" target="_blank" rel="nofollow">www.decontconsulting.com</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EJB PK class