-->
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.  [ 1 post ] 
Author Message
 Post subject: Error generating sql in subclass
PostPosted: Tue Jul 17, 2007 10:18 am 
Newbie

Joined: Thu Mar 22, 2007 7:01 am
Posts: 1
Hi! I'm having a problem with a subclass mapping.

I have this:

IXTraNEntity (Interface, and XTraNEntity is an abstract class)
^
|
+-------------------------------------------------+
| |
Movel CoupledUnit


When I want to load a generic IXTraNEntity, the sql generated is for all proprerties of all the subclasses.
Is that normal?

The problem is that if I uncomment the one-to-one in the Movel subclass, it's not valid and I get an error if I want to get an XTraNEntity that is a coupled unit.
The nhibernate tries to get all the properties.

What can be the solution for this ?


Hibernate version:
1.2.0 GA


Mapping documents:

<class name="DomainModel.XTraNUnit.IXTraNEntity, DomainModel" table="movelDados" discriminator-value="0" lazy="true" polymorphism="explicit">

<id name="IdNum" column="id_num" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<discriminator column="xtran_um_tipo" type="Int32"/>

<property column="versao_movel" type="Byte" name="VersaoMovel" not-null="false" />
<property column="nome" type="String" name="Nome" not-null="false" />
<property column="Ent_desc" name="NomeWeb" not-null="false" />


<subclass name="DomainModel.XTraNUnit.CoupledUnit, DomainModel" discriminator-value="5" lazy="true" dynamic-update="true" >
<property column="matricula" name="Matricula" />
<property column="cod_barras" name="CodigoBarras" />
<property column="tipo" name="Tipo"/>
<property column="capacidade" name="Capacidade"/>
</subclass>


<subclass name="DomainModel.XTraNUnit.Movel, DomainModel" discriminator-value="1" lazy="true" dynamic-update="true">
<property column="logout_tm" name="LogoutWebTm" not-null="false" />

<property column="matricula" name="Matricula" />
<property column="cod_barras" name="CodigoBarras" />
<property column="tipo" name="Tipo"/>
<property column="capacidade" name="Capacidade"/>
<property column="terminal_present" name="TerminalPresent" />
<property column="last_val_campo_1" name="PredefinedConsumption" />


<property column="manut_tipo" name="TipoManutencao" />
<property column="prev_manut_km" name="PrevManutKm" />
<property column="prev_manut_time" name="PrevManutTime" />
<property column="prev_manut_func" name="PrevManutFunc" />
<property column="last_manut_data" name="LastManutTime" />
<property column="last_manut_km" name="LastManutKm" />
<property name="TotalIgnitionTimeLastManut" column="last_manut_func" not-null="false"/>

<!--<one-to-one name="ActualState" class="DomainModel.XTraNUnit.MobileState.MobileStateXTraN, DomainModel" />-->

</subclass>
</class>


Code between sessionFactory.openSession() and session.close():

IXTraNEntity entity = (IXTraNEntity)session.Get(typeof(IXTraNEntity), entityID);



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


The generated SQL (show_sql=true):

SELECT ixtranenti0_.id_num as id1_0_0_, ixtranenti0_.versao_movel as versao27_0_0_,
ixtranenti0_.nome as nome0_0_, ixtranenti0_.Ent_desc as Ent29_0_0_,
ixtranenti0_.matricula as matricula0_0_, ixtranenti0_.cod_barras as cod31_0_0_,
ixtranenti0_.tipo as tipo0_0_, ixtranenti0_.capacidade as capacidade0_0_,
ixtranenti0_.logout_tm as logout34_0_0_, ixtranenti0_.terminal_present as terminal35_0_0_,
ixtranenti0_.last_val_campo_1 as last36_0_0_, ixtranenti0_.manut_tipo as manut37_0_0_,
ixtranenti0_.prev_manut_km as prev38_0_0_, ixtranenti0_.prev_manut_time as prev39_0_0_,
ixtranenti0_.prev_manut_func as prev40_0_0_, ixtranenti0_.last_manut_data as last41_0_0_,
ixtranenti0_.last_manut_km as last42_0_0_, ixtranenti0_.last_manut_func as last43_0_0_,
FROM movelDados ixtranenti0_ WHERE ixtranenti0_.id_num=@p0; @p0 = '8001'




Thank you

Ricardo


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.