EnumType speed up in initEnumValues()

Description

Hi,

I have simplified and sped up the method EnumType.initEnumValues(). See the attached patch.

Tested on Sun JDK 1.6.0_18

Note 1: I do not know, why the author (Emmanuel Bernard?) has used reflection. Maybe the method Class.getEnumConstants() in not implemented by other JREs (IBM, BEA) or he just didn't know this method.?

Note: the method getEnumConstants() in SUN JRE does use the reflection to look for method "values()", too, but it's results are cached, so the second call to the getEnumConstants() is fast. And because the results are cached inside the Enum class itself, it does not cause any memory leaks like HHH-4317.

Activity

Steve EbersoleMarch 21, 2011 at 7:08 PM

Bulk closing stale resolved issues

Kyrill AlyoshinSeptember 5, 2010 at 6:56 AM

Created as a bug.

Kyrill AlyoshinSeptember 5, 2010 at 6:44 AM

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.

Former userAugust 17, 2010 at 8:23 PM

Fixed in trunk and Branch_3_5.

Former userAugust 12, 2010 at 8:12 PM

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

Fixed

Details

Assignee

Reporter

Fix versions

Priority

Created April 22, 2010 at 12:08 PM
Updated April 22, 2015 at 6:24 PM
Resolved May 26, 2010 at 1:10 PM
Loading...