-->
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: Subclass within subclass
PostPosted: Thu May 04, 2006 8:39 am 
Newbie

Joined: Mon Aug 08, 2005 4:53 pm
Posts: 3
Hibernate version: 3.1.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="br.com.sapiensit.sigterra.common.model.bo" default-lazy="false">

<class name="PessoaBO" table="VW_PESSOA" mutable="false">
<id name="id" type="java.lang.Long" column="ID">
<generator class="sequence">
<param name="sequence">SQ_PESSOA</param>
</generator>
</id>
<discriminator column="TP_PESSOA" type="string"/>
<property name="nome" column="NM_PESSOA" not-null="true"/>
<property name="email" column="DS_EMAIL"/>
<property name="tipo" column="TP_PESSOA" insert="false" update="false"/>

<subclass name="PessoaNaturalBO" discriminator-value="1">
<property name="sexo" column="TP_SEXO"/>
<property name="estadoCivil" column="TP_ESTADO_CIVIL"/>
<property name="cpf" column="NR_CPF"/>
</subclass>
<subclass name="PessoaJuridicaBO" discriminator-value="2">
<property name="cnpj" column="NR_CNPJ"/>

<subclass name="CartorioBO">
<join table="TB_CARTORIO" fetch="select">
<key column="ID"/>
</join>
</subclass>
</subclass>
</class>
</hibernate-mapping>


I would like to know if its correct to have a subclass with join and without discriminator. I've searched the forum and found no topic! Sorry for amateur question. The intension here is to simulate a joined-subclass. Is it correct?

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 05, 2006 12:50 am 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
It's fine to put a subclass within a subclass, but I can't see the point of it in your example. Why not just use CartorioBO where PessoaJuridicaBO is currently? There is no requirement to model every class in a hierarchy in the mapping file: hibernate only needs to know about classes that it actually has to instantiate.

_________________
Code tags are your friend. Know them and use them.


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.