On Fri, Sep 11, 2009 at 10:54 AM, RogerV
<roger.varley@xxxxxxxxxxxxxx> wrote:
where platformId, busId and txAddress form a unique identifier that is, in
fact the primary key of both underlying tables.
- Create an @Embeddable class that has these three fields in it. This will end up being your Java class's composite primary key class.
-
Mark each of those fields with the appropriate @Column annotation. For example, one of your composite key member variables might be "businessID", in which case your @Column annotation would be @Column(name = "busId").
- Override its equals() and hashCode() methods so that two instances of this class are equal if and only if all three fields have equal values.
- With that done, go back to your main .java file and give it a field called, say, ID or PK or something similar. Mark that field as being its @EmbeddedId. Its type should be the type of the embeddable class you just created.
- Map that .java file using the @Table annotation to your view.
I hope this helps.
Best,
Laird