Edited for clarity purposes...
Comments inside the text...
>From: Alvaro Mota <[EMAIL PROTECTED]>
>Reply-To: Alvaro Mota <[EMAIL PROTECTED]>
>To: [EMAIL PROTECTED]
>Subject: Class Primary Key
>Date: Thu, 12 Jul 2001 15:19:35 -0300
>
>Hi
>
>"The EJBHome server requires a container-managed entity Bean to have a
>primary key class with a public primary key field (or fields, if using
>composite primary keys).
>Here is the primary key class. The primary key in the Bonus table is
>socsec,
>and so socsec is a public field in this class that is assigned a value when
>the class is constructed.
>
>package com.ejbhome.examples;
>
>public class BonusPK implements java.io.Serializable {
> public int socsec;
>
> public BonusPK(int socsec) {
> this.socsec = socsec;
> }
>
> public BonusPK() {}
>}"
>
>when primary key have fields, is necessary implementation the methods :
>equals(), hashCode() and toString()?
>
>if necessary how make??
Hi Alvaro,
Although you've decided not to hire me, I'll help - you remember me, for
sure.
I generally don�t implement the toString() method, but it's considered to be
a good practice.
Here is how I'd implement equals:
public boolean equals(Object o) {
if ((o == null || !(o instanceof BonusPK)) return false;
if (o == this) return true;
return ((BonusPK)o).socsec == socsec;
}
public int hashCode() {
return socsec;
}
>thank very much
You�re welcome, but I'd like it better if you'd hired me... :-)
----------------------------------------------------
Michael Nascimento Santos
Sun Certified Programmer for the Java 2 Platform
Analista/Consultor
Moderador SouJava - www.soujava.org.br
CPM Sistemas - www.cpm.com.br
>�lvaro Mota Goncalves
>
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".