-->
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.  [ 4 posts ] 
Author Message
 Post subject: superclass table refered in where on hbm.xml
PostPosted: Wed Nov 04, 2009 6:47 am 
Newbie

Joined: Wed Nov 04, 2009 6:15 am
Posts: 2
Hi there,

When, in a hbm, i have a reference to a subclass in a <Set a cannot use the superclasses table fields in the where property of the Set. Is there any way for me reference the superclass table or something like where="super.prop1=123"?

For reference, my mapping files look like this:

The reference to the subclass:
Code:
      <set name="subItems" lazy="true" table="SUBITEMS" where="prop1=123">
         <key>
            <column name="id" />
            <column name="version" />
         </key>
         <one-to-many class="com.sample.SubItem" />
      </set>

The subclass mapping file :
Code:
<hibernate-mapping package="com.sample">

   <joined-subclass name="SubItem" table="SUBITEM" extends="com.sample.Item">
      <key>
         <column name="id" />
         <column name="version" />
      </key>
      
      <property name="name" column="NAME" type="string" not-null="false" length="255" />
   </joined-subclass>
</hibernate-mapping>

The superclass mapping file:
Code:
<hibernate-mapping>
   <class name="com.sample.Item" table="ITEM">
      <composite-id name="id" class="com.sample.Sample$Id" access="field">
         <key-property name="id" />
         <key-property name="version" />
      </composite-id>

      <property name="prop1" column="prop1" type="integer" />
   </class>
</hibernate-mapping>

Any Ideas?

Thanks in advanced


Top
 Profile  
 
 Post subject: Re: superclass table refered in where on hbm.xml
PostPosted: Wed Nov 04, 2009 7:39 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
As the property is not part of the subclass table, you cannot use it in a where, because there you define plain sql.
You need to write a subselect in your where-part.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject: Re: superclass table refered in where on hbm.xml
PostPosted: Wed Nov 04, 2009 7:55 am 
Newbie

Joined: Wed Nov 04, 2009 6:15 am
Posts: 2
I see.

Is there any other way to filter a set of objects based on the value of a property of the superclass in the mapping of the class?


Top
 Profile  
 
 Post subject: Re: superclass table refered in where on hbm.xml
PostPosted: Wed Nov 04, 2009 8:07 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#filters ;-)

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.