-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How to trigger association loading without a connected graph
PostPosted: Tue Jan 30, 2007 12:41 pm 
Beginner
Beginner

Joined: Fri Jan 26, 2007 3:16 pm
Posts: 24
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.