To make your original example work, set primkey-field and prim-key-class to
the following :

<primkey-field>id</primkey-field>
<prim-key-class>java.lang.Long</prim-key-class>

And dump the PersonPK class, you only need that if your primary key is made
up of multiple values.

If you do use the PersonPK class you only need to set prim-key-class :

<prim-key-class>PersonPK</prim-key-class>

jBoss will then use the hashCode (hence the need to implement the hasCode()
method), as the primary key, and will create a database column to hold it. 

When you call findByPrimaryKey and pass in the PersonPK, jBoss will call the
hashCode method and search for a record in the database with it's primary
key set to this hashcode.  If it gets more than one record back, (it is a
hashcode, not a unique id after all), then it will call the equals method on
each of the returned records primary keys to find the match, hence the need
to implement the equals method.

    David Maddison
<< jBoss Evangelist >>



--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to