@JoinFormula and @Generated behave differentlly on java 6 vs. java 8

Description

I have an entity with the following 2 attributes (among others):

1 2 3 4 5 6 7 @Column(name="crypted_insuredpersonid", nullable=false, updatable=false) protected String cryptedInsuredpersonid; @ManyToOne(fetch=FetchType.LAZY) // 1:1 must be n:1 in order for @JoinFormula to work! @JoinFormula(value="crypto.decrypt(crypted_insuredpersonid)", referencedColumnName="insuredpersonid") @Generated(GenerationTime.ALWAYS) protected Insuredperson insuredperson;

This definition works in java 6. The same code and hibernate libraries on java 8 fail during construction of the sessionFactory with the following error:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 weblogic.application.ModuleException: org.hibernate.MappingException: Unknown entity: de.mdk.ismed.persistence.entity.ismed_dev.Insuredperson:org.hibernate.MappingException:Unknown entity: de.mdk.ismed.persistence.entity.ismed_dev.Insuredperson at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:810) at org.hibernate.internal.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:939) at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:553) at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:593) at org.hibernate.type.ManyToOneType.requireIdentifierOrUniqueKeyType(ManyToOneType.java:112) Truncated. see log file for complete stacktrace > <Dec 11, 2018 2:42:25,696 PM CET> <Error> <Console> <BEA-240003> <Administration Console encountered the following error: weblogic.application.ModuleException: org.hibernate.MappingException: Unknown entity: de.mdk.ismed.persistence.entity.ismed_dev.Insuredperson:org.hibernate.MappingException:Unknown entity: de.mdk.ismed.persistence.entity.ismed_dev.Insuredperson at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:810) at org.hibernate.internal.SessionFactoryImpl.getIdentifierType(SessionFactoryImpl.java:939) at org.hibernate.type.EntityType.getIdentifierType(EntityType.java:553) at org.hibernate.type.EntityType.getIdentifierOrUniqueKeyType(EntityType.java:593) at org.hibernate.type.ManyToOneType.requireIdentifierOrUniqueKeyType(ManyToOneType.java:112) at org.hibernate.type.ManyToOneType.getColumnSpan(ManyToOneType.java:108) at org.hibernate.tuple.entity.EntityMetamodel.create(EntityMetamodel.java:444) at org.hibernate.tuple.entity.EntityMetamodel.buildGenerationStrategyPair(EntityMetamodel.java:410) at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:246) at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:518) at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124) at sun.reflect.GeneratedConstructorAccessor1041.newInstance(Unknown Source) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96) at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77) at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:356) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:423) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:711) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:727) at org.springframework.orm.hibernate5.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:511) at org.springframework.orm.hibernate5.LocalSessionFactoryBean.afterPropertiesSet(LocalSessionFactoryBean.java:495)

It states the entity Insuredperson does not exist. However, if I remove the @Generated annotation from the insuredperson attribute, the sessionFactory is constructed without problems on java 8.

I've tested this behaviour with hibernate 5.1.14 and 5.1.15 but the results are the same for both versions.

Environment

hibernate-core:5.1.14, Oracle 11g Database, Windows 7 x64, WebLogic Servers 10.3.6.0 (JDK 1.6.0_45), 12.2.1.3.0 (JDK 1.8.0_152), Spring Framework 4.3.18

Status

Assignee

Unassigned

Reporter

J. Gremmen

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

5.1.14

Components

Affects versions

5.1.14
5.1.15

Priority

Blocker
Configure