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: ILifecycle.OnSave is executing when i call UniqueResult
PostPosted: Fri Apr 25, 2008 8:50 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
I have two BusinessObjects Beleg and BelegZeit (implements ILifecyle) with this mappings:

<class name="Beleg" table="lbkopf">
<id name="BelegNr" column="belegnr" access="field.pascalcase-underscore">
<generator class="assigned" />
</id>
<property name="Von" column="dvon" access="field.pascalcase-underscore"/>
<property name="Bis" column="dbis" access="field.pascalcase-underscore"/>
<bag name="Zeiten" access="field.pascalcase-underscore" order-by="pos" lazy="true" inverse="true" cascade="all">
<key column="belegnr" />
<one-to-many class="BelegZeit" />
</bag>
</class>

<class name="BelegZeit" table="lbzlist">
<composite-id>
<key-many-to-one name="Beleg" column="belegnr" access="field.pascalcase-underscore" />
<key-property name="Pos" column="pos" access="field.pascalcase-underscore" />
</composite-id>
<property name="Datum" column="datum" access="field.pascalcase-underscore"/>
</class>

When i call q.UniqueResult() then bz.OnSave (ILifecycle) is calling. Why? I don't want this behaviour.

using (ITransaction tx = session.BeginTransaction())
{
Beleg b = session.Get<Beleg>(398);
BelegZeit bz = new BelegZeit();
bz.Datum = DateTime.Today;
b.AddZeit(bz);

IQuery q = NHibernateHelper.GetCurrentSession().CreateQuery(
"select max(b.Pos) from BelegZeit as b where b.Beleg.BelegNr = :belegnr");
q.SetInt32("belegnr", b.BelegNr.Value);

object Result = q.UniqueResult();
...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 25, 2008 10:07 am 
Newbie

Joined: Fri Apr 25, 2008 8:19 am
Posts: 17
When i set FlushMode to Commit it works!

using (ITransaction tx = session.BeginTransaction())
{
session.FlushMode = FlushMode.Commit;
...


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.