[jboss-user] [EJB 3.0] - relationship does not prevent from deleting referenced entit
micho
do-not-reply at jboss.com
Wed Feb 21 06:29:58 EST 2007
I thougtht, that the definition of a unidirectional relationship without cascading delet would prevent the Entities from deletion
Example:
unidirectional many-to-many relationship between user and usergroup.
users know their usergroups,
usergroups do not know their users
It shold not be possible to delete a usergroup which is in an relationship to a (or many) user
I coded like this, what have I done wrong?
Thanks Micho
@Entity
| public class Usergroup implements Serializable
| { private long mSid;
| private String mName;
|
| public BenutzerGruppe()
| { super(); }
|
| @Id @GeneratedValue(strategy=GenerationType.AUTO)
| public long getSid()
| { return mSid; }
|
| public void setSid(long sid)
| { mSid = sid; }
|
| public String getName()
| { return mName; }
|
| public void setName(String pName)
| { this.mName = pName; }
| }
|
@Entity
| public class User implements Serializable
| { private long mSid;
| private String mName;
| private List<Usergroup> mUsergrouplist;
|
| public User()
| { super(); }
|
| public String getName()
| { return mName; }
|
| public void setName(String pName)
| { mName = pName;}
|
| @Id @GeneratedValue(strategy=GenerationType.AUTO)
| public long getSid()
| { return mSid; }
|
| public void setSid(long pSid)
| { mSid = pSid; }
|
| @ManyToMany
| ( targetEntity = Usergroup.class )
| public List<Usergroup> getUsergrouplist()
| { return mUsergrouplist; }
|
| public void setUsergrouplist(List<Usergroup> pUsergrouplist)
| { mBenutzerGruppeListe = pBenutzerGruppeListe; }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019859#4019859
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019859
More information about the jboss-user
mailing list