-->
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: query a subclass?
PostPosted: Mon Mar 07, 2005 2:46 pm 
Newbie

Joined: Fri Dec 03, 2004 6:17 pm
Posts: 4
Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 2.1.8

Mapping documents:
<class name="com.test.domainobject.User" table="users">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="sequence">
<param name="sequence">uid_sequence</param>
</generator>
</id>
<list name="accounts" cascade="all" lazy="true">
<key column="user_id"/>
<index column="account_index" />
<one-to-many class="com.test.domainobject.Account"/>
</list>
</class>

<class name="com.test.domainobject.Account" table="account" discriminator-value="ACCT">
<id name="id" type="long" column="id" unsaved-value="0">
<generator class="sequence">
<param name="sequence">uid_sequence</param>
</generator>
</id>
<discriminator column="account_type" type="string"/>
<subclass name="com.test.domainobject.CMAccount" discriminator-value="CM">
<property name="extension" column="extension" type="string"/>
</list>
</subclass>
</class>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
net.sf.hibernate.QueryException: could not resolve property: extension of: com.avaya.pws.domainobject.Account

Name and version of the database you are using: Postgres 7.5

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


I am trying to write a query to return the user with a CMAccount that has an particular extension.

Here is what I started:
select user from User as user join user.accounts as account where account.class = CMAccount and account.extension = '111111'

As you can see from the exception above it sees account as type Account, but I want it to query on properties of the subclass CMAccount...is there a way to do this, or do I need to re-write the query another way?

any help would be appreciated...

thanks


Top
 Profile  
 
 Post subject: Having the same issue.
PostPosted: Fri Nov 18, 2005 1:57 pm 
Newbie

Joined: Fri Nov 18, 2005 1:50 pm
Posts: 5
I am having the exact same problem and was hoping to find a query solution that would work in this case. Does anyone have the answer to this question?


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.