import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;
@Entity
@Table(name = "app_user")
public class User {
@Id
@GeneratedValue
private Integer id;
private String uname;
private String pword;
/*
* one User can have many phone numbers. CascadeType.ALL causes associated
* phone numbers to be delted when a User is deleted.
*/
@ManyToMany(cascade=CascadeType.ALL)
@JoinTable(
name="user_number",
joinColumns = { @JoinColumn( name="user_id") },
inverseJoinColumns = @JoinColumn( name="phone_id")
)
private Set
public User() {
// TODO Auto-generated constructor stub
}
public String toString() {
return "User [id=" + id + ", pword=" + pword + ", uname=" + uname + ", phoneNumbers]";
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getPword() {
return pword;
}
public void setPword(String pword) {
this.pword = pword;
}
public Set
return phoneNumbers;
}
}
No comments:
Post a Comment