Hi,
Since discriminators are ignored for the JOINED strategy, I'm trying to simulator the behaviour with a SINGLE_TABLE strategy and a SecondaryTable for the subclass, as suggested here:
http://opensource.atlassian.com/projects/hibernate/browse/ANN-562
The schema being generated is not as expected - all columns end up in the root table (FORECAST) and USERFORECAST only has an ID column. I end up with non-nullable columns from the subclass in the same table as the root class(which is concrete). Any ideas what I'm doing wrong here or if I'm missing something?
I'm using Hibernate Annotations 3.3.0.GA with Hibernate 3.2.4.sp1.
Code:
@Entity
@Table(name = "FORECAST")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="DISCR", discriminatorType=DiscriminatorType.CHAR)
@DiscriminatorValue("F")
public class Forecast {
@Id @GeneratedValue(strategy=GenerationType.AUTO)
@Column(name="ID")
private long id;
@Column(name = "FORDATE", nullable = false)
private Calendar date;
@Column(name = "TEMPF")
private int temperature;
@Column(name = "OVERVIEW", length = 300)
private String overview;
}
@Entity
@SecondaryTable(name="USER_FORECAST")
@DiscriminatorValue("U")
public class UserForecast extends Forecast {
public static enum CloudType {Cirrus, Cumulus, Status};
@Column(name="USERNAME", length=8, nullable=false)
private String user = null;
@Column(name="CLOUD_TYPE")
@Enumerated(javax.persistence.EnumType.STRING)
private CloudType cloudType = null;
}
Thanks,
Eoin