I am pretty new to Hibernate. My agency is converting hundreds of legacy COBOL programs to java. This also leaves us with a fairly ugly legacy database that is slowly being normalized.
We are still having to use the legacy data prior to the normailization.
Here is the problem I am currently facing:
Two entity classes, each with three column keys, but only two of the columns are shared between the classes.
Example of the two embeddable key objects:
@Embeddable
public class FooKey {
private String fred;
private String barney;
private String bamBam;
.
.
.
}
@Embeddable
public class BarKey {
private String fred;
private String barney;
private Integer pebbles;
.
.
.
}
In our real classes each of the fields also have @Column annotations.
What the business logic calls for is that the Foo class contains a collection of Bar objects and that the one to many association use the columns fred and barney for the join. For purposes of the join bamBam and pebbles should be ignored.
I understand that this is an absolutely horrible data design, but I didn't create it! I just have to make it work.
Additionally, we are supposed to try and handle all of the hibernate mappings using annotations, not hbm files.
Anyone have any ideas? I have tried many of the techniques in the book "Java Persistence with Hibernate", but no success. Possibly(probably) I have made mistakes there.
|