Hi,
I have some problems to map a class in NHybernate which references itself.
The class called "AbstractMarchandise" is abstract and contains a property called "MarchandiseParente" referencing itself
It also contains a list of "childs" of teh same type as "AbstractMarchandise" contained in the property "Composants"
When testing it by searching an object according to its key, I get no mapping error and the object I am looking for is retrieved but "MarchandiseParente" is null and the "Composants" List is empty (whereas I checked by queries that it should contain childs as well as a parent).
I already tried to apply some solutions for similar problems found on internet like the following ones :
http://stackoverflow.com/questions/7551 ... nhibernateor
http://blogs.hibernatingrhinos.com/nhib ... rnate.aspxI am wondering whether my pb is not due to the fact that I am using an abstract class (it is the only difference I noticed between my case and the cases above).
Is there any problem when making self references to abstract classes?
Your help will be appreciated,
Pascal
PS : here is my mapping :Code:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Marchandises" namespace="Marchandises.Business.Marchandises">
<class name="AbstractMarchandise" table="T_MARCHANDISE">
<id name="Cle" column="CLE" type="String" access="eid.property.pascalcase-m-underscore">
<generator class="Marchandises.DataAccess.Hibernate.Marchandises.SequenceMarchandises, Marchandises">
<param name="sequence">SEQ_T_MARCHANDISES</param>
</generator>
</id>
<many-to-one name="MarchandiseParente" class="AbstractMarchandise" column="CLEPARENT" access="eid.property.pascalcase-m-underscore" not-null="false" />
<property name="CleCommandeFournisseur" column="CLECOMMANDEFOURNISSEUR" type="String" access="eid.property.pascalcase-m-underscore" not-null="false" />
<bag name="Composants">
<key column="CLEPARENT" />
<one-to-many class="AbstractMarchandise"/>
</bag>
</class>
</hibernate-mapping>