我在使用标识符的Hibernate实体上有一个@Any映射。回到旧的代码库中,它看起来像这样(我遮盖了对象名称):
<any id-type="long" name="medicalProfessional" meta-type="string" >
<meta-value value="M" class="com.borderconnect.app.domain.company.crew.MedicalProfessional"/>
<meta-value value="D" class="com.borderconnect.app.domain.company.crew.Doctor"/>
<column name="class_type"/>
<column name="medical_professional_id"/>
</any>
现在,我已经将它映射成这样(我已经遮盖了对象名称):
public class SomeClass extends DomainObject {
@AnyMetaDef( name = "medicalProfessional", idType="int4", metaType="string", metaValues = {
@MetaValue( value="M", targetEntity = MedicalProfessional.class ),
@MetaValue( value="D", targetEntity = Doctor.class )
})
@Any( metaColumn = @Column( name="class_type" ), metaDef = "medicalProfessional")
@JoinColumn( name="medical_professional_id" )
private MedicalProfessional medicalProfessional;
据我所知,与此相关的所有其他事物均已正确配置。 MedicalProfessional是@MappedSuperclass,并且具有自己的表。 Doctor是一个实体,并扩展MedicalProfessional,并使用该表。除此之外,这些类都是微不足道的。
启动弹簧引导时,出现“ org.hibernate.MappingException:无法实例化持久化org.hibernate.persister.entity.SingleTableEntityPersister”异常。
Mapping异常似乎又回到了空指针异常:
Caused by: java.lang.NullPointerException
at org.hibernate.tuple.entity.EntityMetamodel.indicatesCollection(EntityMetamodel.java:868) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.tuple.entity.EntityMetamodel.indicatesCollection(EntityMetamodel.java:874) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:289) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:517) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:124) ~[hibernate-support-0.5.1.jar:?]
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
at java.lang.reflect.Constructor.newInstance(Constructor.java:488) ~[?:?]
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:96) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:77) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:348) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:444) ~[hibernate-support-0.5.1.jar:?]
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:879) ~[hibernate-entitymanager-5.0.12.Final.jar:5.0.12.Final]
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60) ~[spring-orm-4.3.19.RELEASE.jar:4.3.19.RELEASE]
仅在需要时,hibernate-support-0.5.1.jar是我提供hibernate 5.0.12的内部依赖项之一。
在我的代码库中,看不到任何空指针或缺少构造函数的明显原因。我对这里可能发生的事情很好奇。我做错了什么吗?我将不胜感激。
答案 0 :(得分:0)
我的问题是@AnyMetaDef中的idType =“ int4”。应该是idType =“ int”