-->
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: Mapping existing POJOs that use List properties for relation
PostPosted: Thu Jun 24, 2004 1:30 pm 
Beginner
Beginner

Joined: Thu Jun 24, 2004 1:04 pm
Posts: 35
Location: Minnesota - USA
Preface this by saying I'm new to Hibernate, but I've been reading everything I can get my hands on for the last month and solving problems as they come up in my coding efforts. Read thru chapter 5 on Hibernate in Action so far. :) BTW, very well written Christian/Gavin.

Anyway, I'm working on a newer version of our persistence layer that uses Hibernate (we've custom DAO framework currently). One thing I've not been able to solve has to do with mapping our existing POJOs which make extensive use of List properties for relations. <set> does not work as these are List properties. And I cannot use <list> because our tables do not have an indexed property.

Changing the POJOs to use Set is _not_ an option at this point. That would be a massive undertaking in many parts of our application. Just do not have the time or man power to do it.

What I'd like would be to use <set> in the .hbm, but have the implementation be with List. Is this possible? (Yes, I know a Set and List are different semantics, but a List can at least be fairly easiliy constrained to Set semantics if you use it properly).

I could also try <bag>, which maps to List in POJOs? But I'm wary of this because of Hibernate's adherence to the semantics. At this point I don't know what headaches might arise later due to that choice.

I've read section 6.2 in the Hibernate (http://www.hibernate.org/hib_docs/refer ... ns-mapping). It which has:
Quote:
If your relational model doesn't have an index column, e.g. if you're working with legacy data, use an unordered Set instead. This seems to put people off who assume that List should just be a more convenient way of accessing an unordered collection.

I understand the argument and agree with it, but I don't see anything here that helps me when I don't have a choice to use Set.

Suggestions? Anyone else worked thru this?

Any help is greatly appreciated.

--gus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 1:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Use a bag


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 1:32 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
And wait for chapter 7 :) It should be out any day now.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 1:33 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Actually, chapter 6. And it is on MEAP.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 24, 2004 1:46 pm 
Beginner
Beginner

Joined: Thu Jun 24, 2004 1:04 pm
Posts: 35
Location: Minnesota - USA
Bleh, MEAP mail notification is tad slow. Apparently been out 2 days already. ;) Thanks, I'll read it ASAP, printing as I write this. --gus


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.