-->
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: Setters and Getters -- Side Effects
PostPosted: Wed Oct 01, 2003 11:38 am 
Beginner
Beginner

Joined: Tue Sep 30, 2003 4:16 pm
Posts: 33
When implementing a "bag" relationship with a collection, is there a difference between the following two models? And would the second snippet possibly cause problems when closing a transaction? Thanks!

Code:
  /**
   * @hibernate.bag
   *  table="ITEMS"
   *  cascade="all"
   * @hibernate.collection-key
   *  column="CHANNEL_ID"
   * @hibernate.collection-one-to-many
   *  class="de.nava.informa.impl.hibernate.Item"
   */
  public Collection getItems() {
    return items;
  }

  public void setItems(Collection items) {
   this.items = items;
  }


versus:
Code:
  /**
...
...
  public void setItems(Collection items) {
    this.items = new ArrayList(items);
  }


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 01, 2003 11:46 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Do NOT use the second! It will cause Hibernate to remove and recreate the collection upon every single flush.


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.