-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with a One-To-Many association unidirectional
PostPosted: Fri Jan 27, 2006 1:08 pm 
Newbie

Joined: Fri Jan 27, 2006 9:00 am
Posts: 2
Hello,

I have a class "Plate" which contains a collection of classes "Well". But the "Well" class don't point to the parent class.
So I have a "Well" table which has a foreign key to the "Plate" table only.

When I call the Session.Save() method, only the data of the Plate class are written in the "Plate" table, and nothing in the "Well" table. And I have no exception.

Could you help me, please ?

Here are my classes and mappings files :

Code:
public class Plate
{
    private string _id;
    private string _name;
    private IList _wells = new ArrayList();

    . . .
}


Code:
public class Well
{
    private string _id;
    private string _name;

    . . .
}


Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="field">

    <class name="BusinessLayer.Plate, BusinessLayer" table="[Plate]">
        <id name="_id" column="Id" type="string">
            <generator class="uuid.hex" />
        </id>
      
        <property name="_name" column="Name" type="String"/>
      
        <bag name="_wells" table="[Well]" inverse="true">
            <key column="Id"/>
            <one-to-many class="BusinessLayer.Well, BusinessLayer"/>
        </bag>
    </class>

</hibernate-mapping>


Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" default-access="field">

    <class name="BusinessLayer.Well, BusinessLayer" table="[Well]">
        <id name="_id" column="Id" type="string">
            <generator class="uuid.hex" />
        </id>
        <property name="_name" column="Name" type="String"/>
    </class>

</hibernate-mapping>



Thank you for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 27, 2006 1:37 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 11:43 am
Posts: 51
Location: Sweden
You shouldn't have inverse="true" in the Plate mapping, since you don't have an association to Plate in the Well class.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

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.