@OneToOneのマッピングとjbossでのデプロイに問題があります。
クラスの階層があります:
@Entity
@Table(name = "SEED")
@Inheritance
@DiscriminatorColumn(name = "ENTITY_TYPE")
@ForceDiscriminator
public class Parent implements Serializable
{
@Id
@SequenceGenerator(name = "SEED_SEQ", sequenceName = "SEED_SEQ")
@GeneratedValue(generator = "SEED_SEQ")
@Column(name = "AA_ID")
protected Long aaId;
@Column(name = "SECRET_SEED")
protected String seed;
@Column(name = "ENTITY_ID")
protected String entityId;
//getters and setters
}
@Entity
@DiscriminatorValue(value = "c1")
public class Child1 extends Parent
{
}
@Entity
@DiscriminatorValue(value = "c2")
public class Child2 extends Parent
{
}
私はこのように子クラスをマップしようとしました:
@Entity
@Table(name = "CLINIC")
public class Clinic implements Serializable
{
@Id
@GeneratedValue(generator = "SEQ_CLINIC_RECID")
@SequenceGenerator(name = "SEQ_CLINIC_RECID", sequenceName = "SEQ_CLINIC_RECID")
@Column(name = "ID")
private Long id;
@Column(name = "CODE")
private String code;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "CODE", referencedColumnName = "ENTITY_ID", insertable = false, updatable = false)
private Child1 child1;
//getters and setters
}
これをjboss-4.2.3.GAにデプロイすると、次の例外が発生します。
org.hibernate.AnnotationException: referencedColumnNames(ENTITY_ID) of setup.entities.Clinic.child1 referencing setup.entities.Child1 not mapped to a single property
at org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:16
5)
at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:63)
at org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:428)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.
java:286)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1115)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1233)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java
:154)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:869)
at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:407)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:126)
hibernate 3.2.6.ga、hibernate-entitymanager3.3.1.gaを使用しています。
なぜこのエラーが発生するのですか?私のマッピングは正しいですか?