• 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
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
  • paul wheaton
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Rob Spoor
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:

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
 
Doe, a deer, a female deer. Ray, a pockeful of sun. Me, a name, I call my tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic