一般的な属性を持つエンティティが2つあります。そのため、以下のような共通のパラメータが抽出されました。JPA ManyToOneマッピングwith継承
@MappedSuperclass()
public class BaseCustomerDemographicDetails {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected long id;
@ManyToOne
@JoinColumn(name = "GROUP")
protected Group group;
}
エンティティスニペットは以下のとおりです。
@Entity
@Table(name = "INDIVIDUAL_CUSTOMER")
@Access(AccessType.FIELD)
public class IndividualCustomer extends BaseCustomerDemographicDetails {
@NotNull
@Embedded
private PersonalInformation personalInformation;
@Column(precision = 16, scale = 2)
private BigDecimal annualIncome;
private Boolean vip;
private Boolean isStaff;
...
}
@Entity
@Access(AccessType.FIELD)
@Table(name = "GROUP")
public class Group {
protected Group(){}
@Id
@NotNull
@Column(name = "GROUPID")
private String groupId;
@NotNull
@Column(name="GROUPNAME")
private String groupName;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "group")
private List<BaseCustomerDemographicDetails> customerDemographicDetails;
}
として以下statrtup中休止例外で同じ結果のOneToManyマッピング。
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1249)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.access$600(EntityManagerFactoryBuilderImpl.java:120)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:860)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:849)
at org.springframework.orm.jpa.vendor.SpringHibernateJpaPersistenceProvider.createContainerEntityManagerFactory(SpringHibernateJpaPersistenceProvider.java:60)
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:343)
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:319)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 16 common frames omitted
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: xx.xxx.xxxxxxx.xxxxxxxxx.domain.model.Group.customerDemographicDetails[xx.xxx.xxxxx.xxxxxxx.domain.model.BaseCustomerDemographicDetails]
at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:1135)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:794)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:729)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
... 24 common frames omitted
公式のドキュメントは、私がやったことと同期していますが、運がないと助けてください!!!!
http://docs.oracle.com/javaee/5/api/javax/persistence/MappedSuperclass.html スタック:春データJPA
あなたはそれを抽象化しようとしましたか? –
ちょうど試した、運がない –
'@OneToMany(fetch = FetchType。プライベートリスト customerDemographicDetails; ' –