-->
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.  [ 2 posts ] 
Author Message
 Post subject: Trouble with single table inheritance
PostPosted: Tue Jan 04, 2011 4:25 pm 
Newbie

Joined: Tue Jan 04, 2011 4:03 pm
Posts: 2
I have a class with basically a lightweight and a heavyweight version. The lightweight class is basically a DTO.

ScanLite is the lightweight class. Scan extends ScanLite and has several additional attributes. Both classes are mapped to the same table.

I have a superclass with at least one subclass. I need to select instances of all subclasses of the superclass. When I run a query to get a list of the superclass I get a Spring InvalidDataAccessResourceUsageException caused by a java.sql.SQLSyntaxErrorException.

This is the superclass:
Code:
@javax.persistence.Entity
@Table(name = "scan")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class ScanLite extends VersionedEntity implements Serializable {
...
}

This is the subclass
Code:
@javax.persistence.Entity
@org.hibernate.annotations.Entity(polymorphism= PolymorphismType.EXPLICIT)
@Table(name = "scan")
public class Scan extends ScanLite implements Serializable {
...
}

This is the query:
Code:
List<ScanLite> scans = ... "FROM ScanLite WHERE serverVersion < ? OR serverVersion IS NULL order by id desc"

This is the error:
Quote:
[java] Caused by: java.sql.SQLSyntaxErrorException: Column 'SCANLITE0_.DTYPE' is either not in any table in the FROM list or appears within a join specification and is outside the scope of the join specification or appears in a HAVING clause and is not in the GROUP BY list. If this is a CREATE or ALTER TABLE statement then 'SCANLITE0_.DTYPE' is not a column in the target table.

What am I doing wrong?

Thanks


Top
 Profile  
 
 Post subject: Re: Trouble with single table inheritance
PostPosted: Thu Feb 17, 2011 4:34 pm 
Newbie

Joined: Thu Feb 17, 2011 2:51 pm
Posts: 1
Hi,

I would like to bump this up. I have a similar problem and I would like to know if there is a solution.

Thanks!


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