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: Strange behaviour with NHibernate and remoting
PostPosted: Fri Sep 29, 2006 4:26 am 
Newbie

Joined: Fri Sep 29, 2006 4:12 am
Posts: 1
*************************UPDATE***************************
I understood the problem myself, I was using serialized DomainModel objects. This means that the objects sent by value instead of reference using remoting. So, the objects id were not updated when inserted.

So, there was no problem with NHibernate.
***********************************************************
Hello,

I'm using NHibernate with remoting and get strange behaviour.

I use a Repository class that encapsulates a session and for each remote call I build a new session and do either SaveOrUpdate or some query.

I have a class "ErrorType" with children "ActionPlanConnectors". When I insert a new "ActionPlanConnector" everthing works fine. But when I update the "ActionPlanConnector" in a subsequent call NHibernate is both updating and inserting my "ActionPlanConnectors" leaving two posts with the same info.

When I use the Repository class locally, without remoting, I have no problem. NHibernate works perfectly. The problem only occurs with remoting.

This is my hbm file:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="DomainModel.ErrorType, DomainModel"
lazy ="false"
dynamic-update="true"
dynamic-insert="true"
select-before-update="true"
table="ERR_TYPES">

<id name="Id" access="field.camelcase-underscore" column="ID" type="Int32" unsaved-value="0" length="4">
<generator class="native" />
</id>
<property name="SequenceNo" column="SEQUENCE_NO" access="field.camelcase-underscore" type="Int32" />
<property name="Damage" column="DAMAGE" access="field.camelcase-underscore" type="Boolean" />
<property name="ActionCode" column="ACTION_CODE" access="field.camelcase-underscore" type="Boolean" />
<property name="RealEstate" column="REAL_ESTATE" access="field.camelcase-underscore" type="Boolean" />
<property name="WorkOrder" column="WORK_ORDER" access="field.camelcase-underscore" type="Boolean" />
<property name="EmergencyAlarm" column="EMERGENCY_ALARM" access="field.camelcase-underscore" type="Boolean" />
<property name="Description" column="DESCRIPTION" access="field.camelcase-underscore" type="AnsiString" not-null="true" length="100"/>

<bag name="ErrorTypeDetails"
access="field.camelcase-underscore"
lazy ="false"
table="REL_DETAIL_TYPE"
inverse="false">
<key column="TYPE_ID"/>
<many-to-many class ="DomainModel.ErrorTypeDetail, Kopplet.DomainModel" >
<column name="DETAIL_ID" />
</many-to-many>
</bag>

<bag name="ActionPlanConnectors"
access="field.camelcase-underscore"
lazy ="false"
table="REL_ACTION"
cascade="all-delete-orphan"
inverse="false">
<key column="ERR_TYPE_ID"/>
<one-to-many class="DomainModel.ActionPlanConnector, Kopplet.DomainModel" />
</bag>
</class>
</hibernate-mapping>

Any help would be greatly apreciated.

Thanks!
Martin


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.