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