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.  [ 2 posts ] 
Author Message
 Post subject: Unmodifiable list with getter
PostPosted: Fri Mar 23, 2007 7:51 pm 
Newbie

Joined: Fri Mar 23, 2007 7:39 pm
Posts: 11
Hi,

If I have a property of type Set in my persistent class, I would like the getter to return an unmodifiable list, to be sure all changes are done through special convenience methods of adding and removing items. Hibernate in Action suggested using Collections.unmodifiableSet which I thought sounded like a good idea. But then I read that returning a different collection from a getter, than the one Hibernate called with the setter, will cause Hibernate to update the database.

So what should I do then?

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 24, 2007 6:49 am 
Newbie

Joined: Wed Jul 05, 2006 1:47 pm
Posts: 6
Location: Belgium
couldn't you just add a POJO method such as pojo.getMySetAsList() which does the logic for you ?
alternatively you could consider setting the property's access to 'field' instead of the default 'property' and wrapping the set in a list using the standard getter:
http://www.hibernate.org/hib_docs/v3/re ... n-property

_________________
wouter [at] andromda [dot] org


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