-->
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: Self reference to abstract class
PostPosted: Fri Jul 23, 2010 4:10 am 
Newbie

Joined: Fri Jul 23, 2010 3:56 am
Posts: 1
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 ... nhibernate
or
http://blogs.hibernatingrhinos.com/nhib ... rnate.aspx

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


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.