-->
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: Strange hibernate requests when merging an Entity.
PostPosted: Tue Jul 31, 2007 4:49 am 
Newbie

Joined: Wed Jun 13, 2007 5:44 am
Posts: 16
Hi.

I noticed a strange behaviour when I'm trying to merge an Entity using the EntityManager.

First of all, the entities:
Code:
@Entity
public class Import implements Serializable {
...
@OneToMany(targetEntity = MicroAction.class, cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
   private List<MicroAction> microActions;
...

Code:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name="microActionType",
    discriminatorType=DiscriminatorType.STRING
)
@DiscriminatorValue("MicroAction")
public abstract class MicroAction implements Serializable{
...


The inheritance is working fine though, so I don't think it's related to the problem.
Speaking of the problem, here's what is happening when I merge an 'Import' into the database (using simply merge method of EntityManager).

Code:
2004 Query       delete from Import_MicroAction where Import_id=1
                   2004 Query       insert into Import_MicroAction (Import_id, microActions_id) values (1, 7)
                   2004 Query       insert into Import_MicroAction (Import_id, microActions_id) values (1, 3)
                   2004 Query       insert into Import_MicroAction (Import_id, microActions_id) values (1, 1)
                   2004 Query       insert into Import_MicroAction (Import_id, microActions_id) values (1, 4)
                   2004 Query       insert into Import_MicroAction (Import_id, microActions_id) values (1, 5)
                   2004 Query       insert into Import_MicroAction (Import_id, microActions_id) values (1, 9)
                   2004 Query       commit


This is the dump of mysql.
Basically, everything is persisted correctly, but why does Hibernate needs to first delete the Import_MicroAction row, can't he just add the missing rows, the ones that wasn't persisted yet?


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.