-->
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: select class objects excluding subclass objects
PostPosted: Wed Sep 14, 2005 2:05 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
I have the mapping below.
DescricaoMaterial has two subclasses: DescricaoMadeira and DescricaoEucalipto.
How can I select only objects from DescricaoMaterial class? I don't want to get instances from DescricaoMadeira and DescricaoEucalipto.

Code:
<hibernate-mapping>

        <class name="src.model.DescricaoMaterial"
           table="DESCRICAO_MATERIAL"
           discriminator-value="DescricaoMaterial">

           <id name="id" column="DESCRICAO_MATERIAL_ID">
              <generator class="sequence">
                 <param name="sequence">
                    DESCRICAO_MATERIAL_GEN
                 </param>
              </generator>
           </id>

           <discriminator column="TIPO" />

           <version name="versao" column="VERSAO" />

           <property name="nome" unique="true" not-null="true" />

           <property name="unidadeMedida" column="UNIDADE_MEDIDA"
              not-null="true" />

           <property name="preco" />

           <subclass name="src.model.DescricaoMadeira"
              discriminator-value="DescricaoMadeira">
              <property name="largura" />
              <property name="altura" />
              <property name="comprimento" />
              <many-to-one name="materialPrimario"
                 column="MATERIAL_PRIMARIO_ID" lazy="false" fetch="join" />
           </subclass>

           <subclass name="src.model.DescricaoEucalipto"
              discriminator-value="DescricaoEucalipto">
              <property name="altura" />
              <many-to-one name="materialPrimario"
                 column="MATERIAL_PRIMARIO_ID" lazy="false" fetch="join" />
           </subclass>

        </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 14, 2005 3:07 pm 
Regular
Regular

Joined: Thu Apr 14, 2005 2:15 pm
Posts: 66
Hi,
I already done.
I achieve this doing this hql query:

"from DescricaoMaterial as descMat where descMat.class = DescricaoMaterial"


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.