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 !!
|