Title: Hibernate Composite Key and Xdoclet

My initial question and response from the xdoclet list.

> --- Eric Mckenna <[EMAIL PROTECTED]> wrote:
> I'm having a problem with xdoclet file merging a
> hibernate composite key
> correctly.  Previously i was just merging in the
> composite id with an
> xdoclet merge file, But after moving to beta3 of
> xdoclet, I keep getting
> "misses ID property" message from xdoclet, since the
> class that uses a
> composite key is does not have an @hibernate.id
> attribute.

> it's recommended by hibernate folks that you define
> class which would be your composite id ( lok for "why
> object being own identity suks" in hibernate docs ).
> Just declare getter of this id class as ID field (
> assigned ) and define properties on his getters.
>

This response made me think i was using the composite class wrong, since he referred to
the getter for the ID relation.  In the System in which I am working,
the RelationTable is used for mapping the relation of two keys (only two columns), so
there is no other class that uses this class as its ID. It's only used to find the relation specified
by the class's two keys and to add new relations.

My composite class looks like this:

/* @hibernate.class table="RelationTable" -- this is the only hibernate tag i previously needed */
public class SomeClass implements Serializable {
 public SomeClass(int compKeyOne, int compKeyTwo) { ... }
 public int getCompKeyOne() {...}
 public int getCompKeyTwo() {...}
 public void setCompKeyOne(int key) {...}
 public void setCompKeyTwo(int key) {...}
 public boolean equals() { ... }
 public int hasCode() { ... }
}

Is this the correct way to use a composite Id?


Thanks,
eric.

Reply via email to