This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

EJB PK class

 
Paulo Aquino
Ranch Hand
Posts: 202
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Rick Hightower
Author
Ranch Hand
Posts: 350
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PK Class
 
Rick Hightower
Author
Ranch Hand
Posts: 350
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Suresh Selvaraj
Ranch Hand
Posts: 104
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic