[jboss-user] [Persistence, JBoss/CMP, Hibernate, Database] - JPA question OneToMany, Cascading
MarcusDidiusFalco
do-not-reply at jboss.com
Wed Oct 3 11:06:59 EDT 2007
Hallo,
I want to use an entity which references a collection of other entities like
| @Entity
| public class Fencer implements Serializable {
|
| @OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
| @JoinColumn(name="fencer_id")
| public List<Tournament> getTournaments() {
| return tournaments;
| }
|
When I detach the fencer entity and change it in a remote client so that an entry from the list is removed and then merge it back with
entityManager.merge(fencer), the entity has the correct state, the deleted entry is gone. But on the DB level the deleted entry in the tournament table still exits. Only the foreign key is set to null.
This behavior is quite unexpected to me. If I do not remove the orphaned entries, the db will fill up with unneeded entries in the detail tables.
How do you implement this correctly to avoid this behavior?
Thanks,
Hans
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4091102#4091102
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4091102
More information about the jboss-user
mailing list