hello
is it possible to have 2 columns in a table (Usr) who keep references to different records
from another table (Member). I want to move a member from a list to another, without
removing and creating a new Member. For example this code:
| //Usr u
| Tournamentmember t = new Tournamentmember();
| t.setUsr(u);
| em.persist(t);
| ...
| //Tournamentmember t
| u.getMembers().remove(t);//delete from one list
| u.getArchivedMembers().add(t);//add to new list
|
make's me to have removed member (t) in members collection too, even if I removed
before (it is in both list!!!). Thanks for help
This are my table:
| @Entity
| class Usr{
| private java.util.Collection<Member> members;
| private java.util.Collection<Member> archivedMembers;
|
| @OneToMany(mappedBy = "usr", fetch = FetchType.LAZY)
| public java.util.Collection<Member> getMembers() {
| return members;
| }
|
|
| public void setMembers(java.util.Collection<Member> members) {
| this.members= members;
| }
|
|
| @OneToMany(mappedBy = "usr", fetch = FetchType.LAZY)
| public java.util.Collection<Member> getArchivedMembers() {
| return archivedMembers;
| }
|
|
| public void setArchivedMembers(java.util.Collection<Member> archivedMembers) {
| this.archivedMembers= archivedMembers;
| }
|
| }
|
| @Entity
| class Member{
| @ManyToOne(fetch = FetchType.EAGER)
| @NotNull
| //@JoinColumn(table="Usr", referencedColumnName = "id")
| public com.joyplay.ejb.persistence.Usr getUsr() {
| return usr;
| }
|
| public void setUsr(com.joyplay.ejb.persistence.Usr usr) {
| this.usr = usr;
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4059574#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...