I think you should have to define the "JoinColumn" for the relations (to really
setup the parent/childs in the same table) :
@Entity
public class ManagedObject {
@Id
@Column(name="ID")
public String getId() {
return dn;
}
public void setId(String dn) {
this.dn = dn;
}
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(name="PARENT")
public Collection getChildren() {
return children;
}
public void setChildren(Collection children) {
this.children = children;
}
@ManyToOne
@JoinColumn(name="PARENT")
public ManagedObject getParent() {
return parent;
}
public void setParent(ManagedObject parent) {
this.parent = parent;
}
private Collection children;
private ManagedObject parent;
private String dn;
}
And then, you can directly delete the parent with
"entityManager.remove(parent)"
(without setting parent.setChildren(null) nor setParent(null) on all children).
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3910540#3910540
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3910540
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user