-->
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: Wrong behavior for @PrePersist/@PreUpdate with em.merge(...)
PostPosted: Thu Aug 21, 2014 5:31 am 
Newbie

Joined: Tue Aug 19, 2014 6:19 am
Posts: 1
I have an entity class like -

Code:
public class Item {
@Id
//mapping
private Long id;

@ElementCollection
//mapping
private Set<ItemWrapper> wrapperSet;

@Transient
private Map<Item, Boolean> itemPredecessor;

..........
..........

@PrePersist
@PreUpdate
private void populateSet() {
    wrapperSet.clear();
    for(Map.Entry<Item, Boolean> entry : itemPredecessor.entrySet()) {
        wrapperSet.add(...);
    }

}
..............
}


Code:
@Embeddable
public class PredecessorWrapper {

    @Column(...)
    private Long dependingId;
    @Column(...)
    private Integer ignoreErrors;

   .......
}


What happens is when I call entityManager.merge(...) with newly instantiated object with itemPredecessor map having some entries in it, hibernate invokes callback method populateSet() with copy of instance passed to merge() which doesn't contain itemPredecessor map with respective entries as itemPredecessor is marked @Transient. When I use entityManager.persist(), it works fine as with actual instance passed to persist() is used to invoke callback method. I am using hibernate 4.3.5. Is this the right behavior?


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.