1 package org.hibernate.test.exception; 3 4 import java.util.Set ; 5 import java.util.HashSet ; 6 7 12 public class User { 13 private Long id; 14 private String username; 15 private Set memberships = new HashSet (); 16 17 public Long getId() { 18 return id; 19 } 20 21 public void setId(Long id) { 22 this.id = id; 23 } 24 25 public String getUsername() { 26 return username; 27 } 28 29 public void setUsername(String username) { 30 this.username = username; 31 } 32 33 public Set getMemberships() { 34 return memberships; 35 } 36 37 public void setMemberships(Set memberships) { 38 this.memberships = memberships; 39 } 40 41 public void addMembership(Group membership) { 42 if (membership == null) { 43 throw new IllegalArgumentException ("Membership to add cannot be null"); 44 } 45 46 this.memberships.add(membership); 47 membership.getMembers().add(this); 48 } 49 } 50 | Popular Tags |