And there are plenty of ways to calculate a hash in standard java
implementations
some are:
MD5
SHA
CRC32
Adler32
Pay attention to the pramati guys, they know what they're doing (I'm a proud
licensee)
Juan Pablo
> -----Original Message-----
> From: Hemant Khandelwal [mailto:[EMAIL PROTECTED]]
> Sent: Jueves, 12 de Julio de 2001 16:03
> To: [EMAIL PROTECTED]
> Subject: Re: Class Primary Key
>
>
> Hi Alvaro,
>
> Besides people obtaining a safe way to implement these
> methods, they also
> need to understand why these methods are necessary. hascode()
> and equals()
> method are used by the hash containers (HashMap, HashSet,
> HashTable) to
> provide faster access to the values in them. Such hash
> containers are used
> by server implementation at different places.
>
> A hash container determines a value (using some algorithm)
> based on the
> hashcode of an Object. Different Objects with the same value
> are put in the
> same bucket.
>
> When a request is recieved by a hash container to access an
> Object, a hash
> container uses same algorithm to determine a value and search
> for the Object
> in a corresponding bucket. Objects in the bucket are compared with the
> target object using equals() method.
>
> So a good spread of hashes from the hashcode() method is
> really important to
> enable fast access when writing user-defined primary key .
>
> Hemant
> www.pramati.com
>
>
> ----- Original Message -----
> From: "Bo Xu" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, July 13, 2001 12:00 AM
> Subject: Re: Class Primary Key
>
>
> Alvaro Mota wrote:
>
> > 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). You can have the container manage
> an enterprise
> > Bean or write the code to manage the Bean yourself. In this
> example, both
> > Beans are container-managed, and you should always let the container
> manage
> > an entity Bean.
> > 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??
> >
> > thank very much
> >
> > �lvaro Mota Goncalves
> > [...]
>
> Hi :-) you can find the discussion about "equals()", "hashCode()",
> "= =", "clone()" in the following:
>
> - Joshua Bloch "Effective Java Programming Language Guide"(ISBN
> 0-201-31005-8)
>
> - http://www.macchiato.com/
>
>
> Bo
> July 12, 2001
>
> ==============================================================
> =============
> 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".
>
> ==============================================================
> =============
> 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".
>
> ______________________________________________________________
> ______________
> For your protection, this e-mail message has been scanned for Viruses.
> Visit us at http://www.neoris.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".