Wrong behavior for @PrePersist/@PreUpdate with entityManager.merge(...)

Description

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(); //itemPredecessor is empty here
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 [entityState -> TRANSIENT] 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.

Note-:
I've debugged in 4.3.5 code base and found that in DefaultMergeEventListener, it does not copy properties which are marked with @Transient.

Environment

None

Assignee

Unassigned

Reporter

Deepak Raut

Fix versions

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure