Hi,
I'm trying out the mixing of inheritance and I'm running into a situation that I think may be a bug.
I have the following classes
Code:
@Entity
@Table(name = "Animal")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorValue(value = "AML")
public class Animal{
@Column
private int eyes = 2;
}
@Entity
@DiscriminatorValue(value = "CAT")
public class Cat extends Animal{
@Column
boolean purs = true;
}
@Entity
@DiscriminatorValue("ELF")
@SecondaryTable(name="Elefant", pkJoinColumns =
{
@PrimaryKeyJoinColumn(name = "animalId", referencedColumnName = "animalId")
}
)
public class Elefant extends Animal{
@Column
boolean protected = true;
}
I run the following query
Code:
DetachedCriteria dc = DetachedCriteria.forClass(Animal.class);
dc.add(Restrictions.eq("eyes", new Integer(2)));
List<Animal> result = getHibernateTemplate().findByCriteria(dc);
I get an error that sais
Unknown column 'this_.protected'
When I review the query, I see that it looks like this
select
this_.eyes,
this_.purs,
this_.protected
from
Animal this_
left outer join
Elefant this_1_
on this_.animalID=this_1_.animalId
where this_.eyes =2;
What I would expect to see is
select
this_.eyes,
this_.purs,
this1_.protected
from
Animal this_
left outer join
Elefant this_1_
on this_.animalID=this_1_.animalId
where this_.eyes =2;
Can anyone enlighten me on either bug or stupidity on my side?
Kind regards,
Marc