-->
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: HQL for querying in single table for class hierarchy mode
PostPosted: Thu May 01, 2008 4:46 pm 
Beginner
Beginner

Joined: Thu Nov 16, 2006 11:34 am
Posts: 26
Location: Boston
Using JPA with Hibernate 3.3 as persistence provider.

Code:
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="type", discriminatorType=DiscriminatorType.STRING)
public class Lov extends BaseEntity {
   private String name;

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }   
}


Code:
@Entity
@DiscriminatorValue("strategy")
public class StrategyType extends Lov {
   
}


BaseEntity is an entity with id, version, create/update dates

My query is "Select s from Strategy s"

I get an error
Code:
Caused by: org.hibernate.hql.ast.QuerySyntaxException: Strategy is not mapped [from Strategy]
   at org.hibernate.hql.ast.util.SessionFactoryHelper.requireClassPersister(SessionFactoryHelper.java:158)
   at org.hibernate.hql.ast.tree.FromElementFactory.addFromElement(FromElementFactory.java:87)



Any ideas how to query inherited objects in a "single table per class hierarchy" mode?

_________________
www.reverttoconsole.com


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 02, 2008 2:55 pm 
Beginner
Beginner

Joined: Thu Nov 16, 2006 11:34 am
Posts: 26
Location: Boston
It was a typo (I should've used StrategyType not Strategy)


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.