-->
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: query reuse, design question
PostPosted: Wed Jun 22, 2005 12:18 pm 
Beginner
Beginner

Joined: Mon Jan 24, 2005 6:42 pm
Posts: 26
My question is around query/database design. What I am running into could be bad schema design, however we are not in a position to re-design at this stage of the game. Also just thinking about it what I am about to describe is probably a valid use case.

As I am creating queries for our object graph I end up writing the same thing over and over again, based on what table/object my graph navigation starts with.

For Example:

We have tables where

A is a main table
B is a table holding different data with a foreigh key to A, where A 1..1 B
C is another table holding foreign key to A where A 1..n C

so if I write queries where I need to start with B's, I also need to fetch A, same goes for C's. In both cases I have to write the same exact thing to load A. Example below illustrates this.

from C c
join fetch c.a a
join fetch a.someobject // identical
etc // identical
where some criteria

from B b
join fetch b.a a
join fetch a.someobject // identical
etc // identical
where some criteria

Is there any way in hibernate to reuse existing query for a specific object in another query, so if I had

from A
join fetch someobject
etc

I could link my queries for C, and B above to a single query that I already have for object A that will load everything necessary.

I hope this makes sense.


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.