Default for CHECK_NULLABILITY does not allow merge retries

Description

The fix for does not work in 3.5.4 when annotations is used or in 3.6.x because nullified transient references are no longer checked because CHECK_NULLABILITY does not default to true.

This is a temporary fix that restores the retry logic from HHH-3229. It only affects the merge operation.

A more general fix that includes persist and save will be covered by HHH-5472.

Environment

None

Activity

Show:
Gail Badner
August 13, 2010, 6:12 AM

When AnnotationConfiguration was merged into Configuration for HHH-5375, CHECK_NULLABILITY was explicitly set for the following tests:

org.hibernate.test.cascade.circle.CascadeMergeToChildBeforeParentTest
org.hibernate.test.cascade.circle.MultiPathCircleCascadeTest
org.hibernate.test.legacy.ComponentNotNullTest

Gail Badner
August 18, 2010, 6:23 AM

Fixed in trunk and Branch_3_5.

Kyrill Alyoshin
September 5, 2010, 4:44 PM

Something happened from 3.5.4 to 3.5.5. Here is regression issue we're experiencing after upgrade:

We have entities ResearchClientFile and ResearchVendorRecord.

RCF maps RVR:

@Sort(type = SortType.NATURAL)
@OneToMany(mappedBy = "file", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
public SortedSet<ResearchVendorRecord> getRecords() {
return records;
}

RVR maps RCF:

@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "research_client_file_id")
public ResearchClientFile getFile() {
return file;
}

The following unit test:

ResearchClientFile rcf = RandomUtils.randomBean(ResearchClientFile.class);
rcf.addRecord(RandomUtils.randomBean(ResearchVendorRecord.class));
rcf = session.merge(rcf);

produces the following exception in 3.5.5 but not in 3.5.4.:

java.lang.NullPointerException: null entities are not supported by org.hibernate.event.def.EventCache
at org.hibernate.event.def.EventCache.containsKey(EventCache.java:80)
at org.hibernate.event.def.DefaultMergeEventListener.mergeTransientEntity(DefaultMergeEventListener.java:361)
at org.hibernate.event.def.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:303)
at org.hibernate.event.def.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:258)
at org.hibernate.impl.SessionImpl.fireMerge(SessionImpl.java:869)

equals, hashCode and compareTo are completely consistent in RVR.

The issue seems to affects only Set and SortedSets and on merge only. Lists (with bag semantics) do not appear to be affected on merge.

Of all the things touched in 3.5.5 (according to the changelog) this issue seems to be the only one dealing with merge functionality, so I decided to put a comment here. I will also create a bug that described this in detail.

Kyrill Alyoshin
September 5, 2010, 4:56 PM

Created as a bug.

Steve Ebersole
March 22, 2011, 6:08 AM

Bulk closing stale resolved issues

Fixed

Assignee

Gail Badner

Reporter

Gail Badner

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major