-->
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: How update child with null parent
PostPosted: Thu Mar 17, 2016 3:36 pm 
Newbie

Joined: Sun Feb 28, 2016 3:16 pm
Posts: 17
Current code does not do update for child with null parent.
CATEGORY_PARENT_ID should be null instead of 1 for record with CATEGORY_ID = 1 after update.
What I need to change for proper child updating?

I am passing child POJO to update method, here is toString() of it (parent is null):
Code:
{"id":2}

DbUnit setup dataset:
Code:
<dataset>
<CATEGORY CATEGORY_ID="1"
<CATEGORY CATEGORY_ID="2"
CATEGORY_PARENT_ID="1"/>
</dataset>

DbUnit expected dataset:
Code:
<dataset>
<CATEGORY CATEGORY_ID="1"/>
<CATEGORY CATEGORY_ID="2"/>
</dataset>   

Java code:
Code:
@OneToOne( cascade = {CascadeType.ALL})
@JoinColumn(name = "CATEGORY_PARENT_ID")
@NotFound(action = NotFoundAction.IGNORE)
private Category parent;
@OneToMany( orphanRemoval = true, mappedBy = "parent", cascade = {CascadeType.ALL})
@NotFound(action = NotFoundAction.IGNORE)
private List<Category> children;
//...
getHibernateTemplate().merge(entity);


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.