I just checked. This Windsor configuration is very similar to what ayende
was using in his Alexandria sample.
In my case Windsor is responsible for disposing of the object.

Greetings Daniel

On 11.09.2010, at 16:48, "José F. Romaniello" <[email protected]>
wrote:

You can use CurrentSessionContext, inject ISessionFactory in your
DAOs/REpositories/QueryObject/Whatever and use sf.GetCurrentSession() (or
sf.OpenSession() when you need)



2010/9/11 Daniel Hölbling <[email protected]>

> How would you change that?
>
>
> On 11.09.2010, at 15:22, Fabio Maulo <[email protected]> wrote:
>
> mmmmmm
>  Component.For<ISession>().UsingFactoryMethod(sessionFactory.OpenSession)
>             .LifeStyle.Is(LifestyleType.Transient)
> this is smell a lot
>
> On Sat, Sep 11, 2010 at 10:11 AM, Daniel Hölbling < <[email protected]>
> [email protected]> wrote:
>
>> This is my Windsor configuration:
>>
>> public void Install(IWindsorContainer container, IConfigurationStore
>> store)
>> {
>>     container.Kernel.AddFacility("factory", new FactorySupportFacility());
>>     container.Kernel.AddFacility("logging", new
>> LoggingFacility(LoggerImplementation.Log4net, "log4net.config"));
>>     container.Register(
>>         Component.For<ISessionFactory>().Instance(sessionFactory),
>>
>>  Component.For<ISession>().UsingFactoryMethod(sessionFactory.OpenSession)
>>             .LifeStyle.Is(LifestyleType.Transient)
>>         );
>> }
>>
>> I agree Fabio, this has to be some sort of problem in my configuration. By
>> I seriously can't find anything that's wrong. I open a session at the
>> beginning of a message handler, wrapped in a distributed transaction and
>> when the transaction commits the changes to my entity should persist to the
>> Database.
>> They just don't and I have no reasonable explanation for it.
>>
>> This is btw the Fluent NH code that configures NH:
>>
>> public ISessionFactory CreateSessionFactory(bool buildSchema = false)
>> {
>>     var persistenceConfigurer = configuration.GetDatabase();
>>     var autoPersistenceModel =
>>         AutoMap.AssemblyOf<AggregateRoot>(new AutomappingConfig());
>>
>>     return Fluently.Configure()
>>         .Database(persistenceConfigurer)
>>         .Mappings(m =>
>>                         {
>>                             m.AutoMappings.Add(autoPersistenceModel);
>>                         })
>>         .ExposeConfiguration(SetEventListeners)
>>         .ExposeConfiguration((cfg) => { if (buildSchema) BuildSchema(cfg);
>> })
>>         .ExposeConfiguration(UpdateSchema)
>>         .BuildSessionFactory();
>> }
>>
>> greetings Daniel
>>
>> On Sat, Sep 11, 2010 at 2:28 PM, Fabio Maulo < <[email protected]>
>> [email protected]> wrote:
>>
>>> If you write that code in a pure-100%-NH-based-test you will see an
>>> update.
>>>
>>> On Fri, Sep 10, 2010 at 9:34 PM, Daniel Hölbling <<[email protected]>
>>> [email protected]> wrote:
>>>
>>>> I've just spent almost 3 hours debugging and still can't find a fault
>>>> with my code.
>>>>
>>>> The reproduction looks like this:
>>>>
>>>> using (var tx = session.BeginTransaction())
>>>> {
>>>>     var product = session.Get<Product>(message.ProductDto.Id);
>>>>     product.Name = message.ProductDto.Name;
>>>>     product.PartNumber = message.ProductDto.PartNumber;
>>>>     product.Price = message.ProductDto.Price;
>>>>     session.Update(product);
>>>>     tx.Commit();
>>>>     Logger.InfoFormat("Updated Product {0}", product.Id);
>>>> }
>>>>
>>>> I change some value of the entity in the UI, this code is run (over the
>>>> wire) and the IsDirty() Method is set to False and no Update is generated.
>>>> (Checked with NHProf..)
>>>> I just re-checked and upon changing the value of product.PartNumber for
>>>> 8 times it didn't generate a UPDATE once.
>>>>
>>>> It gets significantly worse once I run this with distributed
>>>> transactions from NServiceBus where I loose every second UPDATE to the
>>>> database without any error or anything.. It just doesn't update the DB 
>>>> since
>>>> it doesn't think the session is dirty.
>>>>
>>>> Is there anything I should be aware of?
>>>>
>>>> greetings Daniel
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "nhusers" group.
>>>> To post to this group, send email to <[email protected]>
>>>> [email protected].
>>>> To unsubscribe from this group, send email to
>>>> <nhusers%[email protected]>
>>>> [email protected].
>>>> For more options, visit this group at
>>>> <http://groups.google.com/group/nhusers?hl=en>
>>>> http://groups.google.com/group/nhusers?hl=en.
>>>>
>>>
>>>
>>>
>>> --
>>> Fabio Maulo
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google Groups
>>> "nhusers" group.
>>> To post to this group, send email to <[email protected]>
>>> [email protected].
>>> To unsubscribe from this group, send email to
>>> <nhusers%[email protected]>
>>> [email protected].
>>> For more options, visit this group at
>>> <http://groups.google.com/group/nhusers?hl=en>
>>> http://groups.google.com/group/nhusers?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To post to this group, send email to <[email protected]>
>> [email protected].
>> To unsubscribe from this group, send email to
>> <nhusers%[email protected]>
>> [email protected].
>> For more options, visit this group at
>> <http://groups.google.com/group/nhusers?hl=en>
>> http://groups.google.com/group/nhusers?hl=en.
>>
>
>
>
> --
> Fabio Maulo
>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" 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/nhusers?hl=en.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>

 --
You received this message because you are subscribed to the Google Groups
"nhusers" 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/nhusers?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" 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/nhusers?hl=en.

Reply via email to