The general pattern for something like that is:
- Create an @Embeddable class to hold all the raw types (3 ints, or 3 longs, or whatever your PK type is) named after the columns to keep things simple). - Map it in your TableC entity class with @EmbeddedId. - Map the two foreign key properties as you normally would, with @ManyToOne and @JoinColumn. Add "insertable=false" and "updatable=false" to the @JoinColumn mappings. - Now you can refer to these non-insertable and non-updatable properties in the mappedBy attribute of your @OneToMany properties in TableA and TableB's entities.
The JPA2 way of doing it would be to use @MapsId annotations, but I've had problems with that and Hibernate so I just use the old method described above.
|