-->
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: Query on polymorphic association
PostPosted: Mon Oct 19, 2009 8:35 pm 
Beginner
Beginner

Joined: Wed Jun 28, 2006 2:24 pm
Posts: 30
Location: Brazil
I'm trying to perform the following query on a polymorphic association:

from Pessoa where nome = 'Rafael';

But Unknown column 'pessoa1_1_.nome' in 'where clause' error is raised.

The mapping is:

Code:
<class name="Pessoa" table="bs_com_pessoa">

  <id name="id" type="java.lang.Long">
    <generator class="native"/>     
  </id>

  <joined-subclass name="PessoaFisica" table="bs_com_pessoa_fisica">
    <key column="id_pessoa"/>
    <property column="nome" name="nome" not-null="true"/>
  </joined-subclass>

  <joined-subclass name="PessoaJuridica" table="bs_com_pessoa_juridica">
    <key column="id_pessoa"/>
    <property name="razaoSocial" column="razao_social" not-null="true"/>
    <property name="nomeFantasia" column="nome_fantasia" not-null="true"/>     
  </joined-subclass>

</class>

<class name="Cliente" table="bs_erp_cliente">

  <id name="id" type="java.lang.Integer">   
    <generator class="native"/>     
  </id>

  <many-to-one name="pessoa" class="Pessoa" column="id_pessoa" not-null="true" unique="true" cascade="all"/>

</class>


This query is supported? What I'm missing?

Thanks


Top
 Profile  
 
 Post subject: Re: Query on polymorphic association
PostPosted: Mon Oct 19, 2009 11:18 pm 
Beginner
Beginner

Joined: Wed Apr 18, 2007 6:17 pm
Posts: 49
Location: Dominican Republic
Hello Rafael i think that you're not missing anything in the mapping but you're querying with a field that in the class
Perssoa doesn't exist, this only work for the fields of the Perssoa class as a part of the base hierarchy. You can try the cod
from below

Code:
from PerssoaFisica p where p.nome='Rafael'


Regards,


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.