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
|