Hello,
I'm fairly new to hibernate and have a "probably" simple question.
For my project I have a simple class hierarchy:
Code:
abstract class PersistentObject {
Long id;
Set<PersistentObject> connections;
}
class Address extends PersistentObject {
}
class Appointment extends PersistentObject {
}
Now I want to be able to link arbitrary objects (Address -> Address, Address -> Appointment, Address -> AnotherObject, ...) with each other and store them inside the set. I do not want to specifiy an association table for each connection type.
In SQL I would think, I need another table containing the following columns:
Code:
LINK_TABLE
---------------------------------
TABLENAME1 | ID1 | TABLENAME2 | ID2
Is there a way to represent that using hibernates <set> ? I'll probably need a composite key, but since the name of the class isn't part of the class itself, hibernate doesn't allow it.