-->
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: CreateCriteria.List throw a MappingException
PostPosted: Thu Nov 02, 2006 8:27 am 
Newbie

Joined: Thu Nov 02, 2006 8:13 am
Posts: 1
Location: Montpellier, France
Hello,
I've a big problem with all request object (Criteria, Find, ...)
when I throw the query (via .List or .UniqueResult())
NHibernate throw me a MappingException and I don't know why !

The problem is very strange because if I reexecute the same fonction just above, the fonction is well executed !
as an example :

ICriteria criteria = _ISession.CreateCriteria(typeof(InscriptionPro));
criteria.Add(Expression.Like("Login",_login));
criteria.Add(Expression.Like("PWD",_PWD));
InscriptionPro ip=null;
try{
ip = (InscriptionPro)criteria.UniqueResult(); <--- Mapping Exception !!
}catch(Exception e){
ip = (InscriptionPro)criteria.UniqueResult(); <--- OK, it's well ?!
}

but InscriptionPro is a joined-subclass of Inscription (whith many fields)
and even if with the "try hack" I've got an InscriptionPro object, the Inscription Object (super class) is not initialized (SetFetch ?)

the two object are mapping like this :
Inscription.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<class name="Melody.MelodyServices.Inscription, MelodyServices" table="DT_USER" lazy="true" mutable="true">
<id name="Id" column="USR_NUM_PK" unsaved-value="0">
<generator class="identity"/>
</id>
<property name="Nom" column="USR_STR_FIRSTNAME" not-null="true" type="System.String"/>
<property name="Prenom" column="USR_STR_LASTNAME" not-null="true" type="System.String"/>
</class>
</hibernate-mapping>

InscriptionPro.hbm.xml
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="property">
<joined-subclass name="Melody.MelodyServices.InscriptionPro, MelodyServices" table="DT_PRO" extends="Melody.MelodyServices.Inscription, MelodyServices">
<key column="USR_NUM_FK" />
<property name="Login" column="PRO_STR_LOGIN" not-null="true" unique="true" type="System.String"/>
<property name="PWD" column="PRO_STR_MDP" not-null="true" type="System.String"/>
</joined-subclass>
</hibernate-mapping>

If you have an idea to work Criteria well and how retrieve a complete object... thank's a lot !!


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.