• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

EJB PK class

 
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Author
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PK Class
 
Rick Hightower
Author
Posts: 350
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
I've been selected to go to the moon! All thanks to this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic