-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Removal of an element of an 1.N collection
PostPosted: Fri Jun 08, 2007 8:02 am 
Beginner
Beginner

Joined: Thu Feb 22, 2007 6:08 am
Posts: 35
Hi there!

I have an entity that have a 1.N collection that has the follow cascade option:
Code:
@OneToMany(cascade = { CascadeType.PERSIST,
CascadeType.MERGE,
CascadeType.REMOVE },
mappedBy = "imovelHabitacional")
private List<Images> images = new ArrayList<Images>();


On the servlet, the entities are treat has detached entities, and to persist and update i do this

Code:
EntityManagerFactory emf = HibernateUtil.getEntityManagerFactory();
EntityManager em = emf.createEntityManager();
EntityTransaction tx = em.getTransaction();
tx.begin();
em.merge(imovelHabitacional);
tx.commit();
em.close();


every thing works fine on the creation of the "imovelHabitacional" entity. If i change that new entity, by adding an image to the "images" list, that new image is added to the DB by an insert, and the main entity is updated too. But when i remove an image from that list, nothing is done. That image still on the DB.

Does anyone know what am i doing (or not doing) wrong?

Thanks a lot!

--ms


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.