[EJB 3.0] - relationship does not prevent from deleting referenced entit
by micho
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
19Â years, 2Â months
[EJB 3.0] - Re: One PersistenceUnit, multiple DataSources
by 7rond
OK, just as an update - I've figured out that bundling the war inside another ear - also containing a jar with a new persistence.xml that maps to the war's datasource works as intended.
Now bundling the war like this:
| webapp1.ear
| -> webapp1.war
| -> webapp1-persistence.jar
| -> persistence.xml
|
Though, in my original persistence.xml, I point to the jar files containing my entity beans, but in the webapp-ear I cannot do that as it doesn't seem like you can point on jar files inside another ear - so I instead have to point on every single class inside myproject.ear that acts as an entity-bean.
This is surely a maintenance-hell when a new entity gets introduced and I need to change all these persistence.xml's in the webapps, rebuild and redeploy.
Is there any way to be able to point to those jars even if they are inside another EAR?
Some kind of "inherited persistence.xml" would be damn sexy here :(
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4019842#4019842
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4019842
19Â years, 2Â months