-->
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.  [ 6 posts ] 
Author Message
 Post subject: Mapping Classes for grouping rows
PostPosted: Mon Feb 02, 2004 3:54 pm 
Newbie

Joined: Fri Dec 12, 2003 7:50 am
Posts: 3
I have a table (REPORT) which contains 3 columns:

GROUP
REPORT_NAME
CLASS
PROCESS

All of these are part of the primary key. I would like to create an object model such that a GROUP object contains a collection of REPORT objects, each of which has a name, class and process as properties.

Is this possible to do in hibernate, given that there is only one table

cheers,

rob


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 02, 2004 4:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Don't think this is possible in an easy way.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 3:04 pm 
Newbie

Joined: Fri Dec 12, 2003 7:50 am
Posts: 3
No, I can't think of any easy way either. Can you think of any hard way?
Basically, out of the back of the mapping, I somehow need to generate 2 objects instead of one: one for the grouping and one for the row.

I was thinking perhaps I should use some kind of custom-value type might do it. Or maybe even a composite key. Somehow I could use a type of singleton so that each key with the same group has a reference to the group in it.

There are actually a couple of different places in the (really bad) schema I'm working with where this would really come in useful.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 6:49 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Actually the only thing that comes to my mind currently is writing a custom ClassPersister, which is HARD. I am not so sure you could be able to do it that way, as you essentially are trying to map one object to multiple table rows.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 03, 2004 7:00 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Actually I would really try to solve this on the database side, using some views or something. I have the strong feeling this is a MySql db though ...


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 22, 2007 12:15 pm 
Newbie

Joined: Mon May 21, 2007 4:41 pm
Posts: 2
I came across this and was wondering if anyone had found a reasonable solution to this to date?

I ended up doing something similar, using a <subselect> in the equivalent of the GROUP mapping discussed above. This page has a decent description of the approach:
http://blog.exadel.com/?p=16

The problem was that doing a select distinct on the table I was using was far too slow.

Just curious if anyone else has any thoughts.

-Matt


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.