-->
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.  [ 8 posts ] 
Author Message
 Post subject: Problem with PolymorphismType.EXPLICIT
PostPosted: Tue Apr 18, 2006 9:30 am 
Newbie

Joined: Tue Apr 18, 2006 9:21 am
Posts: 2
@Entity(access = AccessType.FIELD)
@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT)
@Table(name = "TableA")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class ObjectA{

@Entity(access = AccessType.FIELD)
@Table(name = "TableB")
public class ObjectB extends ObjectA{

When we call ObjectA ("findByKey") the Hibernate always use union select with TableB, but the expect is select only TableA , because we use polymorphism = PolymorphismType.EXPLICIT.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 10:13 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Quote:
because we use polymorphism = PolymorphismType.EXPLICIT.


I don't think this is what EXPLICIT is meant for.

How else should it find out which instance to load?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 11:15 am 
Newbie

Joined: Tue Apr 18, 2006 9:21 am
Posts: 2
Hibernate, by default, look for class and extends class (PolymorphismType.IMPLICIT (default)). I just want an instance of ObjectA not the ObjectA and all instance of ObjectB extends ObjectA. I don’t want any of their superclasses.

So I try to use PolymorphismType.EXPLICIT, like I did in XML <class...polymorphism="explicit"...>)

But,
@org.hibernate.annotations.Entity(polymorphism = PolymorphismType.EXPLICIT),
don’t work as expect.

ObjectA X.getObjectA(); (return more than one result, because use union select ObjectB)

I’m accepting suggest.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 18, 2006 12:55 pm 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Then don't use inheritance.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 27, 2006 9:24 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
can you open a jira issue with a running test case of both hbm working and annotations failing. That would help me to see what's wrong.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: was this ever fixed
PostPosted: Mon Mar 05, 2007 2:53 pm 
Beginner
Beginner

Joined: Thu Sep 16, 2004 8:14 pm
Posts: 27
Looks like this thread is a few years old, but I'm seeing the same thing with Hibernate 3 where PolymorphismType.EXPLICIT is not preventing subclasses from being returned in the results. Hibernate is using a union to include the superclass (which I do want to find) and its subclass (which I don't want to be grabbed polymorphically).


Top
 Profile  
 
 Post subject: oops
PostPosted: Mon Mar 05, 2007 2:59 pm 
Beginner
Beginner

Joined: Thu Sep 16, 2004 8:14 pm
Posts: 27
er, sorry, got my threads mixed up. Looks like this issue isn't that old.

Also, I am using annotations and have not tried using the EXPLICIT polymorphism type in a hbm file.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 07, 2007 8:37 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
no jira issue has been posted AFAIK

_________________
Emmanuel


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

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.