| I have an entity with the following 2 attributes (among others):
@Column(name="crypted_insuredpersonid", nullable=false, updatable=false)
protected String cryptedInsuredpersonid;
@ManyToOne(fetch=FetchType.LAZY) @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:
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. |