Could please anybody provide example with PolymorphismType.EXPLICIT in effect;
Code:
@Entity
@org.hibernate.annotations.Entity(polymorphism=org.hibernate.annotations.PolymorphismType.EXPLICIT)
@Inheritance(strategy=InheritanceType.JOINED)
public class Animal{
...
}
@Entity
public class Dog extends Animal{
...
}
@Entity
public class Cat extends Animal{
...
}
When i run this part of code:
Code:
EntityManager em = emf.createEntityManager();
Animal a = em.find(Animal.class, id);
i would expect sql:
SELECT * FROM Animal WHERE id = ?
but (regardless from PolymorphismType) i always get:
select a,b.*,c.*
case
when b.id is not null then 1
when c.id is not null then 2
when a.id is not null then 0
end as clazz_1_,
from Animal a
left outer join Dog b on a.id=b.id
left outer join Cat c on a.id=c.id
where a.id=?