-->
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: Session isdirty true immediately after loading objects?
PostPosted: Sat Apr 08, 2006 12:18 pm 
Newbie

Joined: Fri Apr 07, 2006 7:36 am
Posts: 5
Location: Linz, Austria
Why is session.IsDirty() true immediately after loading objects?
Each flush generates several unnecessary update statements.

Whats wrong?

tia cybere


code
-----------------
ICriteria crit = Session.CreateCriteria(typeof(BLogic.Ads.Advertising))
.Add(Expression.IsNull("Parent"));

Debug.Print(Session.IsDirty().ToString()); //false

IList items = crit
.AddOrder(Order.Asc("ClassID"))
.AddOrder(Order.Asc("Description"))
.List();

Debug.Print(Session.IsDirty().ToString()); //true
-----------------

private ISession Session {
get {
if (_session == null || !_session.IsOpen) {
_factory = Data.Connection.Factory;
_session = _factory.OpenSession();
_session.FlushMode = FlushMode.Commit;
}
return _session;
}
set { _session = value; }
}
-----------------


mapping
-----------------

The class Advertising refers to itself to make a hierachical grouping of ads possible.


<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="BLogic.Ads.Advertising, BLogic" table="tAdvertising"
dynamic-update="true">
<id name="OID"
........unsaved-value="{00000000-0000-0000-0000-000000000000}">
........<generator class="guid"/></id>
........<many-to-one name="Parent" column="Parent"
................class="BLogic.Ads.Advertising, BLogic"/>
................<bag name="Children" inverse="true" lazy="true" >
................<key column="Parent" />
................<one-to-many class="BLogic.Ads.Advertising, BLogic" />
................</bag>

........<property name="ClassID" type="Int32"/>
........<property name="Code" type="String(25)" length="25"/>
........<property name="Description" type="String" length="30"/>
........<property name="Costs" type="Decimal"/>
........<property name="Active" type="Boolean"/>
........<property name="CreatedDate" type="Date"/>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 6:18 am 
Newbie

Joined: Fri Apr 07, 2006 7:36 am
Posts: 5
Location: Linz, Austria
the problem was in the mapping file.

didn't know how to store an enum correct.

this leads to IsDirty true immediatly after loading and unnecassary updates
Code:
<property name="ClassID" type="int32"/>


this is working correct
Code:
<property name="ClassID" type="BLogic.Ads.AdType, BLogic"/>


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.