[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4975?page=c...
]
Christian Fritschi commented on HHH-4975:
-----------------------------------------
I found a dirty workaround:
Replace this:
@ManyToOne(optional=false)
@JoinColumn(name="MASTER", nullable=true,
referencedColumnName="MASTER_ID")
private MasterUk1 master;
With this:
@ManyToOne(optional=false, targetEntity=MasterUkBase.class)
@JoinColumn(name="MASTER", nullable=true,
referencedColumnName="MASTER_ID")
private MasterUk1 master;
This will work only for One-Level in the Subclassing hirarchy, what if we have mor then
one level ?
ManyToOne and referencedColumnName and MappedSuperclass (2 Levels)
=> org.hibernate.AnnotationException: referencedColumnNames ... not mapped to a single
property
------------------------------------------------------------------------------------------------------------------------------------------------------------------
Key: HHH-4975
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-4975
Project: Hibernate Core
Issue Type: Bug
Components: annotations
Affects Versions: 3.3.2
Environment: Hibernate version 3.3.2.GA, HSQLDB 1.8.0.10
Reporter: Christian Fritschi
Priority: Critical
Attachments: startTestDb.rar, ukMapping.rar, UkMappingTest.java
Level 1 (superClass)
-------
@MappedSuperclass
public abstract class AbstractMasterUk ...
@Id
private int id;
....
@Column(name="MASTER_ID", nullable = false, length=50)
private String masterId;
Level 2 (superClass)
-------
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@Table(name="MASTER_UK")
@DiscriminatorColumn(name="DOMAIN",
discriminatorType=DiscriminatorType.STRING)
public class MasterUkBase extends AbstractMasterUk ....
Parent-Class
------------
@Entity
@org.hibernate.annotations.Entity(mutable = false)
@DiscriminatorValue(MasterUk1.DOMAIN)
public class MasterUk1 extends MasterUkBase ...
Child-Class
-----------
@Entity
@Table(name="DETAIL_UK")
public class DetailUk implements Serializable {
@Id
private int id;
@ManyToOne(optional=false)
@JoinColumn(name="MASTER", nullable=true,
referencedColumnName="MASTER_ID")
private MasterUk1 master;
Result:
org.hibernate.AnnotationException: referencedColumnNames(MASTER_ID) of
annotations.playground.delta.ukMapping.DetailUk.master referencing
annotations.playground.delta.ukMapping.MasterUk1 not mapped to a single property
at
org.hibernate.cfg.BinderHelper.createSyntheticPropertyReference(BinderHelper.java:180)
at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:88)
at
org.hibernate.cfg.AnnotationConfiguration.processEndOfQueue(AnnotationConfiguration.java:456)
at
org.hibernate.cfg.AnnotationConfiguration.processFkSecondPassInOrder(AnnotationConfiguration.java:438)
at
org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:309)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1333)
at
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:867)
.....
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira