There's a bunch of failing tests in the NCVIB branch where I put a sample
for some other problem before, at
https://github.com/ncvib/NCVIB/tree/inspectiondb in the
IntegrationTest.NCVIB.Repositories.InspectionObjectRepository class. I'll
find a specific one to point to tomorrow, when I'm at work and have the code
infront of me.

I'll gladly help with the docs if I can - I'm not sure I understand much of
how the library works, though, so I might not be of much help. But I'll do
my best =)

// Tomas


On Thu, Jul 21, 2011 at 21:20, Henrik Feldt <[email protected]> wrote:

> Hello Tomas,
>
> Can you provide a failing unit test?
>
> If I help you fix this, would you help me update the documentation?
>
> Henrik
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Tomas Lycken
> Sent: den 20 juli 2011 13:42
> To: Castle Project Users
> Subject: Transaction attribute not orchestrating transactions as expected
>
> Hi everybody,
>
> I have a generic repository base class for my NHibernate repositories,
> Repository<TEntity>, in which I want to provide a couple of standard
> methods
> within transactions. I'm using the Castle.Services.Transaction, together
> with Castle.Facilities.AutoTx and Castle.Facilities.NHibernate
>
>    public abstract class Repository<TEntity> where TEntity :
> IEntity // common entity interface that declares int ID { get; }
>    {
>        protected Func<ISession> SessionGetter;
>
>        public Repository(Func<ISession> sessionGetter) { SessionGetter =
> sessionGetter; }
>
>        [Transaction(Mode = TransactionScopeOption.Required)]
>        protected virtual void Save(TEntity entity)
>        {
>            var session = sessionGetter();
>            session.Save(entity);
>        }
>    }
>
> When I call this method from a repository implementation, I get an
> exception
> saying "Castle.Facilities.AutoTx.MissingTransactionException : No
> transaction in context when trying to instantiate model
> 'NHibernate.ISession' for resolve type 'NHibernate.ISession'. If you have
> verified that your call stack contains a method with the [Transaction]
> attribute, then also make sure that you have registered the AutoTx
> Facility." If I put the attribute on the calling method, everything works -
> but I want to be able to throw and catch exceptions in the calling methods
> without having to worry about the transaction committing or rolling back,
> so
> I'd like to isolate the db work in small methods that orchestrate a
> transaction, do its job and then commits (or rolls back and bubbles the
> exception).
>
> I am not familiar enough with the castle project to really understand
> what's
> going on behind the scenes here, and the documentation I've found (here:
> http://docs.castleproject.org/Windsor.ATM-Facility.ashx)
> is pretty sparse and mildly outdated.
>
> Please advise if this is doable - and if so, how. Thanks!
>
> --
> 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.
>
> --
> 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.
>
>

-- 
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