[hibernate-issues] [Hibernate-JIRA] Commented: (EJB-261) merge fails to update join table
Emmanuel Bernard (JIRA)
noreply at atlassian.com
Fri Feb 16 00:47:40 EST 2007
[ http://opensource.atlassian.com/projects/hibernate/browse/EJB-261?page=comments#action_26128 ]
Emmanuel Bernard commented on EJB-261:
--------------------------------------
Hi Bryan, I can't reproduce the issue anymore (I remember I did), can you try on your side to see if Hibernate Core 3.2.2 fixed it by side effect?
> merge fails to update join table
> --------------------------------
>
> Key: EJB-261
> URL: http://opensource.atlassian.com/projects/hibernate/browse/EJB-261
> Project: Hibernate Entity Manager
> Type: Bug
> Components: EntityManager
> Versions: 3.2.1
> Environment: Embedded entity manager 3.2.1 with DB2 or MySQL
> Reporter: Bryan Hunt
> Priority: Minor
> Attachments: hibernate.bug.zip
>
>
> Doing a merge on an entity with a one to many relationship does not update the join table.
> I have the following entities:
> @Entity
> public class Foo
> {
> ...
> @OneToMany(cascade = CascadeType.ALL)
> private Set<Bar> bars;
> }
> @Entity
> public class Bar
> {
> ...
> }
> The following works:
> Foo foo = new Foo();
> Bar bar = new Bar();
> foo.getBars().add(bar);
> em.getTransaction().begin();
> em.persist(foo); // <<----------------- correctly updates the join table
> em.getTransaction().commit();
> This also works:
> Foo foo = em.find(Foo.class, id);
> Bar bar = new Bar();
> foo.getBars().add(bar);
> em.getTransaction().begin();
> em.persist(bar);
> em.merge(foo); // <<----------------- correctly updates the join table
> em.getTransaction().commit();
> When this code executes the new Foo and Bar are persisted to the database, an entry is made into the join table, and all is well.
> The following fails:
> Foo foo = em.find(Foo.class, id);
> Bar bar = new Bar();
> foo.getBars().add(bar);
> em.getTransaction().begin();
> em.merge(foo); // <<----------------- does not update the join table
> em.getTransaction().commit();
> When this code executes, the new Bar is persisted to the database, but the join table is not updated.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list