-->
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: Loading base types with polymorphic entities
PostPosted: Wed Jan 02, 2008 5:41 am 
Newbie

Joined: Wed Jan 02, 2008 5:32 am
Posts: 1
Hibernate version:
NHibernate 1.2

Mapping documents:
Code:
<class name="Person" table="Person" lazy="false">
  <id name="ID" column="ID" type="Int32" unsaved-value="-1">
    <generator class="native"/>
  </id>
  <property column="Forename" type="String" name="Forename" length="50" />
  <property column="Surname" type="String" name="Surname" length="50" />
</class>

<joined-subclass name="Employee" extends="Person" table="Employee" lazy="false">
  <key column="PersonID" />
  <property column="LoginName" type="String" name="LoginName" length="50" />
</joined-subclass>

Name and version of the database you are using:
SQL Server 2005

Hi All,

As you can see above, we have two entity types, Person and Employee, which are treated polymorphically (i.e. Employee derives from Person) and uses the table-per-subclass approach. I'm struggling to find a NHibernate query (pref using a Criteria expression rather than HQL) which will give me all Person entities that are not Employees. Please can someone suggest some way of doing this?

TIA,
John


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 02, 2008 2:05 pm 
Expert
Expert

Joined: Fri May 13, 2005 11:13 am
Posts: 292
Location: Rochester, NY
I think the 'class' HQL keyword is also available in Criteria queries. See near the end of 11.7 ( http://www.hibernate.org/hib_docs/nhibe ... yhql-where )

It may still match polymorphically, though.

Actually, have you tried polymorphism=explicit? http://www.hibernate.org/hib_docs/nhibe ... tion-class


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.