-->
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.  [ 1 post ] 
Author Message
 Post subject: Simple Bi-Directional Link Semantics
PostPosted: Tue Jun 14, 2005 12:57 pm 
Newbie

Joined: Tue Jun 14, 2005 12:27 pm
Posts: 2
What is the standard way to access the collections used for bi-directional links (see Hibernate Reference section 2.3.6)? I would like to prevent "everybody else from messing with the collections directly," but still need to be able to get all the elements of the collection. In the example in the reference, this isn't possible:

Code:
protected Set getEvents() {
    return events;
}

protected void setEvents(Set events) {
    this.events = events;
}
public void addToEvent(Event event) {
     this.getEvents().add(event);
    event.getParticipants().add(this);
}
public void removeFromEvent(Event event) {
    this.getEvents().remove(event);
    event.getParticipants().remove(this);
}


Do I need to return a read-only wrapper for the events getter and use field access to the set, or am I missing something obvious?

Ryan


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

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.