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: Extra unwanted properties in collection mapping.
PostPosted: Wed Dec 16, 2009 12:11 pm 
Newbie

Joined: Wed Dec 16, 2009 11:54 am
Posts: 2
Hello fellow nhibernate enthusiasts,

I recently started working with nhibernate and like most people here ive come across a fair share of problems. My latest problem is a mstery to me and I could use some help with it.

I will try give a short summary.

I have a parent class with a bag mapping (rest omitted)

Code:
<bag name="Waardes" lazy="false">
      <key column="RegelID"/>
      <one-to-many class="DocumentBodyregelWaarde,
                          BusinessObjects"/>
</bag>


and the mapping for the 'bagged' class:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping  xmlns="urn:nhibernate-mapping-2.2">

  <class name="DocumentBodyregelWaarde,
               BusinessObjects"
         table="DocumentBodyRegelWaarde">
   
    <id name="ID" column="ID">
      <generator class="native"/>
    </id>

    <property name="RegelID" column="RegelID"/>
    <property name="DocumentID" column="DocumentID"/>
    <property name="Regeltype" column="RegelType"/>
    <property name="Volgorde" column="Volgorde"/>
    <property name="XMLveldnaam" column="XMLVeldnaam"/>
    <property name="XMLveldwaarde" column="XMLVeldwaarde"/>   

  </class>
</hibernate-mapping>



The situation i was trying to create here is that when i load a entity of the parent class, it would load the child class.
This actually works. But with a twist. When i look up the created SQL in NhibernateProfiler, it shows the following:

Code:
SELECT waardes0_.RegelID       as RegelID1_,
       waardes0_.ID            as ID1_,
       waardes0_.ID            as ID18_0_,
       waardes0_.RegelID       as RegelID18_0_,
       waardes0_.DocumentID    as DocumentID18_0_,
       waardes0_.RegelType     as RegelType18_0_,
       waardes0_.Volgorde      as Volgorde18_0_,
       waardes0_.XMLVeldnaam   as XMLVeldn6_18_0_,
       waardes0_.XMLVeldwaarde as XMLVeldw7_18_0_
FROM   DocumentBodyRegelWaarde waardes0_
WHERE  waardes0_.RegelID = 17038240 /* @p0 */


As can be seen, 2 of the properties are requested twice. But I have no idea why, i've tried for a different mapping with set, but this results in the same query. Also an outer-join results in the two properties being requested twice.

Is the problem staring me in the face, or should i look for the problem elsewhere?


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.