Hello, I understand the RTFM, and I'm about half-way through the 800 page tome, but I haven't yet seen an answer to this, and I'm hoping it is a simple question, and someone can provide a simple answer or point me to the right place to find it.
Here's a simple object model:
Code:
public class ThingA {
private long id;
private int typeId;
...
}
public class ThingB {
private long id;
private int typeId;
...
}
These things are actually different behaviorally and in the data they contain based on the typeId. We can map them directly to TABLE_A and TABLE_B without a problem.
These things may also have some association between them, but it is not a real java pointer association. We have a separate object that links them relationally in memory:
Code:
public class ThingAssociation {
private long srcId;
private long tgtId;
...
}
The ThingAssociation can be mapped pretty easily from mapping tables or the relational foreign key columns in various tables.
A Cache with Maps is used in-memory that will fetch all associated things for you; given you have one Thing, you can get all its other associated things from this in-memory cache.
The question is this:
Say I query for all ThingA's in the database, and say I've defined mappings for ThingA, ThingB, and ThingAssociation. How can I trigger Hibernate to know that it should also go fetch the mappings for ThingAssociation, and the linked ThingB objects?
Most examples for associations in the docs/book have actual java reference pointers between objects. This model is missing that (it is more in-memory relational). What are the options for triggering the load?
Thx in advance,
Davis