-->
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.  [ 5 posts ] 
Author Message
 Post subject: data retrieval using hibernate ..
PostPosted: Sat Mar 04, 2006 3:33 am 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
Hibernate version: 3.1.2

i have a problem that is more related to software design than hibernate in specific . i am not sure if this is the right place to ask it :)

i have a DAO that contains data retrieval logic in several formats .
One time , i may want a list of rows with a specific number of fields in it, and other time i may ask for same rows with another set of fields . if this kind of senario happens , my DAO may become unmanagable with similar but different data retrieval functions . how could i do it in a more compact / generic way .

i think most of you have experienced it and may help me how to solve it .

thanks in advance ...

_________________
sHeRiN
thanks for your ratings ...... :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 11:36 pm 
Beginner
Beginner

Joined: Thu Nov 11, 2004 12:18 pm
Posts: 37
Location: Baltimore, MD
I think what you may be looking for is the use of discriminators.

Basically you'd have an object hierarchy that maps to a single table. Each subclass in this hierarchy represents a different set of columns in a given table. Your parent class would specify all common columns (the PK, etc), and would specify which column is the discriminator for the child objects. Each child object would specify it's own discriminator, as well as the columns it needs to map.

Check out the reference documentation, http://www.hibernate.org/hib_docs/v3/reference/en/html_single/ and search for "discriminator"

_________________
-Chris


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 07, 2006 11:41 pm 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
i was not talking about the inheritence hierarchy and the discriminator . my case is of a single table with say 50 columns in it . i just want to avoid the redundant code for fetching data , since my requirements varies from a single table itself .

im hoping for some generic solutios or a pattern that helps me doing it in a generic way , anyways thnx for the reply . i will appreciate more suggestions on it :)

_________________
sHeRiN
thanks for your ratings ...... :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 12:50 pm 
Beginner
Beginner

Joined: Thu Nov 11, 2004 12:18 pm
Posts: 37
Location: Baltimore, MD
Are the columns you need static, or would they change frequently? If they would be generally the same, you should be able to create multiple entities that map to the same table, each only specifying a subset of the available columns.

_________________
-Chris


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 08, 2006 11:34 pm 
Regular
Regular

Joined: Tue Dec 14, 2004 5:21 am
Posts: 104
Location: india
TheXFed wrote:
Are the columns you need static, or would they change frequently? If they would be generally the same, you should be able to create multiple entities that map to the same table, each only specifying a subset of the available columns.



i'll explain it in detail once more

1) suppose i have a table with 80 fields
2) i never rule out the chances of fields being static
2) at time t1 i need to retrieve fields f1,f2,...f10
time t2 i need fields f5,f2,...f15
time tn i need fields fn,...fm
3) if i am going to provide a method for each t's in my DAO , i will be drowned in my DAO class
4) if i load all the fields each time , i may have performance probs (what if i have 500 tables like this and i have limited memory and processing power)
5) all these cases apply to more number of tables . so multiple mapping on a table is not encouraged
6) the problem is increased if i retrieve the data in different collections like list , set or map each time

i really need a design pattern or a generic class that deals with this situation :)

can i make use of the new generic DAO class mentioned in hiberate.org . And i'll be happy to rethink on my application design / schema design at this point of time .

_________________
sHeRiN
thanks for your ratings ...... :)


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

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.