That was interesting, although i don't have this problem.

Also i will check how to add and use PreUpdateEventListener, since i
need to implement audit for all of my business entities



On Jul 9, 10:30 pm, "Cesar Sanz" <[email protected]> wrote:
> Hello again,
>
> I found this interesting 
> linkhttp://fabiomaulo.blogspot.com/2008/10/how-test-your-mappings-ghostbu...where
>  I could understood
> why my entity was getting updated.
>
> In my model I have a class named [Client] which utilize an enumerator as 
> custom type,
> well, my model said the ColumnType for Status property was Int32, while in 
> the fact it was of ClientStatus Type
>
>         [Property("Status"), ColumnType="Int32"]
>
>         public virtual ClientStatus Status
>
>         {
>
>             get { return _status; }
>
>             set { _status = value; }
>
>         }
>
> NHbibernate doesn't throws any execption because ClientStatus is convertible 
> to Int32
>
> but when the session is disposed, NHibernate see my Client model as dirty.
>
> All I had to do was to remove this column type and it looks like this now:
>
>         [Property("Status")]
>
>         public virtual ClientStatus Status
>
>         {
>
>             get { return _status; }
>
>             set { _status = value; }
>
>         }
>
> Everything is perfect know!
>
> Hope this thread helps some other people like it helps me
>
> Thank you Makus..
>
> ----- Original Message -----
>
>   From: Markus Zywitza
>   To: [email protected]
>   Sent: Thursday, July 09, 2009 9:31 AM
>   Subject: Re: Why AR is Updating When Performing a Select
>
>   you can add an PreUpdateEventListener and compare the cached and actual 
> object states to find the changes.
>
>   -Markus
>
>   2009/7/9 Cesar Sanz <[email protected]>
>
>     Hello markus and Thanx
>
>     using (new SessionScope(FlushAction.Never)) did works!
>
>     >Normally, if there is no change in the objects, nothing happens (the 
> entities are not dirty).
>
>     Normally?? Is there a chance that this happens without entities not been 
> dirty?
>
>     >If you experience flushing after a simple load, check whether your code 
> changes anything in the entities.
>
>     I followed my code and no changes are made. Is there a way to check if my 
> entity is dirty? Can NHibernate shows me
>     the changes...
>
>     Thanx for answering
>
>     ----- Original Message -----
>       From: Markus Zywitza
>       To: [email protected]
>       Sent: Thursday, July 09, 2009 12:02 AM
>       Subject: Re: Why AR is Updating When Performing a Select
>
>       When AR/NH loads entities, it puts them into a cache. When the 
> session(scope) disposes, the objects in the cache are checked whether they 
> have been changed and the changes are written back (flushed) to the DB.
>
>       Normally, if there is no change in the objects, nothing happens (the 
> entities are not dirty). If you experience flushing after a simple load, 
> check whether your code changes anything in the entities.
>
>       As a workaround, you can load your entities in a separate read-only 
> sessionscope:
>
>       using (new SessionScope(FlushAction.Never))
>       {
>        // Load here
>       }
>       // Don't access lazy properties here!!!
>
>       The downside is that you can't access lazy properties in your view 
> templates.
>
>       -Markus
>
>       2009/7/9 [email protected] <[email protected]>
>
>         Hello..
>
>         I am in a hurry cuz I have to release a small project.
>
>         I use AR for this project, my model is simple,
>
>         [Client] has many [Product]
>
>         This is used in a web application, so a new session is opened on each
>         request.
>
>         The point is.. when I perform a Client.FindAll() it select all the
>         clients (which is desirable) but at
>         the end of the request, I can see AR is updating each and every client
>         that found..
>
>         I see no changes are really made.. So, I don't know what is happening
>         under the hood..
>
>         I appreciate any kind of help.
>
>         Best regards
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to