Hibernate version: Hibernate 3.2 RC2
Hibernate annotations version: Hibernate Annotations RC1
Code:
@Entity
@Table(schema = "cmn", name = "tb_lookup")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "fk_lkt", discriminatorType = DiscriminatorType.STRING)
@SequenceGenerator(name = SimpleDomainObject.SEQUENCE_ALIAS, allocationSize = 1, sequenceName = "cmn.sq_lookup")
public abstract class Lookup extends SimpleDomainObject {
@Id
private Long id;
@Column(name = "title")
private String title;
...
}
Code:
@Entity
@DiscriminatorValue("account-type")
public class AccountType extends Lookup {
}
and
Code:
@MappedSuperclass
public abstract class LookupAware<L extends Lookup> {
@Id
private Long id;
@ManyToOne
@JoinColumn("fk_lookup")
private L lookup;
....
}
Code:
@Entity
@Table(name="accountTypeAware")
public class AccountTypeAware extends LookupAware<AccountType > {
@Column("name")
private String name;
...
}
Well, in hibernate startup an exception occures:
so it seems that hibernate uses introspection for determining the property types!
I've changed
Code:
@MappedSuperclass
public abstract class LookupAware<L extends Lookup> {
@Id
private Long id;
public abstract L getLookup();
public abstract void setLookup(L lookup);
....
}
Code:
@Entity
@Table(name="agentTypeAware")
public class AccountTypeAware extends LookupAware<AccountType> {
@ManyToOne(targetEntity = AccountType.class)
@JoinColumn("fk_lookup")
private AccountTypelookup;
@Column("rate")
private Double rate;
public AccountTypegetLookup() {
return lookup;
}
public void setLookup(AccountTypelookup) {
this.lookup = lookup;
}
...
}
Still same exception happens on hibernate startup! But When I read property types in second solution, the property types are not Lookup and are of its child type!
How can I handle this?