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