Hi Verkaz,
You could also turn on logging for NH. which would tell you what happening
w/o doing a purchase.
Something like this in App.config
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<log4net>
<appender name="NHibernateFileLog"
type="log4net.Appender.RollingFileAppender">
<file value="logs/nhibernate.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="1"/>
<maximumFileSize value="200KB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss.fff}
[%t] %-5p %c -> %m%n"/>
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the
default priority -->
<root>
<priority value="ALL"/>
<appender-ref ref="trace"/>
</root>
<logger name="NHibernate" additivity="false">
<level value="WARN"/>
<appender-ref ref="trace"/>
<appender-ref ref="NHibernateFileLog"/>
</logger>
</log4net>
</configuration>
You need to use transactions when you save/update things, if you're not, it
might not commit.
With transactions, you mostly never need to call Flush.
With one ISession per application, it might fill up over time, depending on
what you use it for. It can in the end amount to a lot of code running
checking collections and references being dirty every time you make a save.
Since they are cheap to create, you might as well create one. One session
factory per app though.
Cheers
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of vekaz turkovic
Sent: den 26 maj 2009 20:31
To: [email protected]
Subject: Re: Castle AR, getting data from DB, not the cache
Hi Jason,
Thank you for your reply. That is not harsh at all. I am well aware of the
mistake I made. I was so frustrated with linq, that I just had to drop it
and quickly replace it with something else. Even without any previous
experience with NHibernate/AR, it seemed far more intuitive and capable than
Linq, and I decided to use it. Even with the problems I have, I don't regret
one bit.
I read just about everything I could find on the web about AR/NH session
management, but most of it is talking about web apps.
Also, a lot of it is just adding to my confusion. For example, some people
say using one session for application is a 'time bomb', other people
('Hibernate in Action', IIRC) say it is just the right way... Another
example. I found many articles suggesting Session.Clear() should be called
after Session.Flush(), but then I find Ayende's '...if you're calling
Clear(), you're doing something weird...'
If something I wrote sounds rude or in any way inappropriate, my apologies.
Again, thanks for your reply. Downloading nhprof it right away.
Jason Meckley wrote:
> This may be harsh, but your first mistake was blindly applying a
> framework to a project which is almost complete.
>
>> I made a quick switch from Linq to Sql to AR near the end of a project,
and didn't have the time to properly learn AR/NHibernate before I started
using it.
>>
>
> As for advice on what the problem may be:
> 1. Start by reading the documentation on AR and NH session management.
> (AR is primarily about attributes, so I venture to say most of the
> problems are with session management). AR is not a silver bullet or
> magic potion for data access you must understand the tool to use it
> properly.
> 2. Get a license for NHProf (www.nhprof.com) and profile your
> application. This will tell you the cause of your problems. Since you
> have now read the documentation you can begin to solve the pain
> points.
>
> On May 26, 12:40 pm, vekaz turkovic <[email protected]> wrote:
>
>> Hi all,
>>
>> I am using Castle AR in a WinForms application. I made a quick switch
>> from Linq to Sql to AR near the end of a project, and didn't have the
>> time to properly learn AR/NHibernate before I started using it.
>> So, be gentle, this may be a really stupid question...
>>
>> Several users run the application simultaneously. I want to reload
>> the data from the database each time a user saves something. I am
>> getting the data using the same code when a form is first loaded, and
>> later, after data is saved. This seemed to work ok, until I tested
>> the app with two users using the app simultaneously. First user saves
>> stuff, second user tries to reload the data, but he doesn't see the
>> changes made by the first user until the app is restarted.
>>
>> If i dispose the current scope and create a new one, everything works
>> perfectly, but it takes forever to complete. If I run the application
>> on my desktop computer, the same computer where the SQL Server is,
>> everything is fine. But, when I run it on my laptop, and connect to
>> the server through the network, the process of saving, disposing the
>> current scope, creating a new one and reloading the data (which is
>> usually just several records) takes about 10 seconds.
>>
>> Is there any other way of forcing AR to get the data from the DB, not
>> the cache? Or, am i doing all this completely wrong?
>>
>> I need to find solution to this asap, any suggestions are very welcome.
>>
>> Thanks in advance.
>>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---