Question

I seem to miss something here :

I have an application that uses a session per application method and using lazy loading.

I've set the session FlushMode.Commit and it seems that NHibernate still auto saves my dirty objects to the DB (SQLCe) although I never begin a transaction and commit it.

can anyone tell me what am I doing wrong ?

some of my code :

    public Repository(ISessionProvider sessionProvider)
    {
        _sessionProvider = sessionProvider;
        _session = _sessionProvider.OpenSession();
        _session.FlushMode = FlushMode.Commit;
    }

    public IList<T> GetAll<T>() where T : class
    {
        var criteria = _session.CreateCriteria<T>();
        var list = criteria.List<T>();
        return list;
    }
Was it helpful?

Solution

It seems that I had another thread that was flushing the same session while I was creating a dirty object in my UI, I guess it was just a bug in my application.

works Great now, still using a session per application since I need the Lazy feature.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top