-->
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: Merge causes second insert in same transaction
PostPosted: Wed Sep 16, 2009 11:43 am 
Newbie

Joined: Fri Mar 07, 2008 11:47 am
Posts: 2
In one transaction I do the following:

organizationDAO.create(organization);

// create client use org_id for client_id
Client client = new Client(organization.getOrgId());
client.setClientName(organization.getOrgName());
clientDAO.create(client);

// create clients OrgType
orgTypeClient = new OrgType();
orgTypeClient.setClientId(client.getClientId());
orgTypeDAO.create(orgTypeClient);

// update organization with this orgType and client id
organization.setOrgTypeId(orgTypeClient.getOrgTypeId());
organization.setClientId(client.getClientId());
organizationDAO.flush();
organizationDAO.clear();
organizationDAO.update(organization);

This creates a second organization record instead of merging the first inserted record.

I need this in one transaction so that I don't fail any constraints. They setup a cyclical dependency between the tables, so I need to do an insert then update.

How do I get the call to merge not insert?


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.