-->
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.  [ 9 posts ] 
Author Message
 Post subject: EJB3.0 Beta1 problems with query over inheritance
PostPosted: Tue Jun 28, 2005 7:29 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 4:16 pm
Posts: 27
Hi all, I am using the brand new EJB3.0 Beta1, but I am having a problem with an issue that did not happen using the Preview5.
I have implemented a single-table per class strategy (entities that extend a superclass, all mapped to the same table and using a discriminator). I have everything as the documentation tells:

For the superclass:

Code:
@Entity
@Table(name = "message_event")
@Inheritance(strategy = SINGLE_TABLE, discriminatorType = CHAR, discriminatorValue = "-")
@DiscriminatorColumn(name = "event_type")
@SequenceGenerator(name="seq_event", sequenceName="seq_event")
public class Event implements Serializable {
...
}


and, for instance, a subclass:
Code:
@Entity
@Inheritance(discriminatorValue="I")
public class InfoEvent extends Event{
...
}


If I create a query or a criteria looking for all entities 'from PersEvent' I get this exception:
Quote:
org.hibernate.WrongClassException: Object with id: 2 was not of the specified subclass: com.test.PersEvent


The object with id 2 isa InfoEvent (that extends Event), so no exception should be thrown. I did not happend using the Preview 5,

Has anybody else observed this behaviour? Am I missing something?

Regards,

Bruno


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 4:15 am 
Beginner
Beginner

Joined: Mon Mar 14, 2005 4:16 pm
Posts: 27
Found the reason of this issue and I think it is a bug. If you use the @Column metadata for the attribute id, the polymorphic query files, but if you don't put the @Column (id column is created by default) everything works as expected...

Regards,

Bruno


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 01, 2005 9:52 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can you post a runnable test case to JIRA please, I'll look at it.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 5:59 am 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
Some more info on this.

I'm using the same thing and have found that when i run the query and have a look at the generated SQL, the discriminator ciolumn is missing.

This causes hibernate to give the above exception as it cannot determine the class type.

I'll remove the @Column annotation from the id and see what diff that makes.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 6:06 am 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
Yep sure enough, i removed the @Column tag from the @Id property in the superclass and now my testcase works.

The query runs fine and the discriminator column is now present at the end of the column list.

So, this must be a bug.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 6:16 am 
Beginner
Beginner

Joined: Sun Jun 13, 2004 9:49 pm
Posts: 38
It's not the @Column tag itself, but the name attribute. The existence of the annotation is ok, but if you rename the id column then the discriminator vanishes.

Shall i raise this as a bug?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 12:44 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
post a runnable test case and I'll look at it

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 04, 2005 12:43 pm 
Newbie

Joined: Wed Mar 03, 2004 11:22 am
Posts: 12
I have experienced this same problem - has a JIRA issue been created for it?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 06, 2005 9:39 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
This bug is solved in Hibernate3 core HEAD

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 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.