-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: PolymorphismType.EXPLICIT
PostPosted: Fri Jan 07, 2011 10:48 am 
Newbie

Joined: Fri Jan 07, 2011 10:18 am
Posts: 1
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=?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.