ATM - Readonly transactions.

1 view
Skip to first unread message

Jordan

unread,
May 4, 2010, 11:55:16 AM5/4/10
to Castle Project Development List
Hello everyone,

I've just made some changes to Services.Transactions, NHibernate
integration and ATM to add support for readonly transactions. I feel
this could be a really useful addition.

Basically, I've added a ReadOnly parameter to the
TransactionAttribute. This flag is then passed to the ResourceAdapter
in NHibernate intergration which temporarily sets the FlushMode to
FlushMode.Never for the duration of the transaction.

Is this something you would be interested in reviewing? If so, would
you like some patches?

regards,
Jordan.

--
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-pro...@googlegroups.com.
To unsubscribe from this group, send email to castle-project-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en.

Krzysztof Koźmic

unread,
May 4, 2010, 12:00:22 PM5/4/10
to castle-pro...@googlegroups.com
Jordan,

I think the most convenient option would be to fork the projects on
Github and then send pull requests with your changes.

cheers,
Krzysztof

Jordan

unread,
May 4, 2010, 12:12:37 PM5/4/10
to Castle Project Development List
Hi Krzysztof,

Thanks for the reply. Sorry, I'm a git novice, do you mean clicking on
the "fork" button links on the relevant castle pages on github.com?
If so, I presume I need an account for that?

regards,
Jordan.


On May 4, 5:00 pm, Krzysztof Koźmic <krzysztof.koz...@gmail.com>
wrote:

Henry Conceição

unread,
May 4, 2010, 12:16:26 PM5/4/10
to castle-pro...@googlegroups.com
Why do you want to a readonly transaction? A readonly session isn't enough?

Cheers,
Henry Conceição

Jordan

unread,
May 4, 2010, 12:27:40 PM5/4/10
to Castle Project Development List
Hi Henry,

Readonly transactions are something that is provided by Spring.NET and
various Java persistence frameworks (EJB3, Spring). I find them useful
when working with NHibernate to prevent unwanted commits of dirty
objects.

Imagine the following scenario in a 3 tiered application (Web/Service/
Data Access) where the transactions are managed at the Service level
by ATM:

- Transactional service 1 is called and makes some modifications to an
entity which fail validiation, so the transaction is rolled back.
- Transaction service 2 is called by the web front end to retrieve
some data to display to the user in the next screen.

If service 2 is not run in a read only transaction then the previous
changes made to the entity in service 1 will be commited to the
database, despite the previous transaction being rolled back.

There may be other (better) examples of why it is useful, but this is
one that I have encountered.

regards,
Jordan.


On May 4, 5:16 pm, Henry Conceição <henry.concei...@gmail.com> wrote:
> Why do you want to a readonly transaction? A readonly session isn't enough?
>
> Cheers,
> Henry Conceição
>
>
>
> On Tue, May 4, 2010 at 12:55 PM, Jordan <augustusgor...@yahoo.co.uk> wrote:
> > Hello everyone,
>
> > I've just made some changes to Services.Transactions, NHibernate
> > integration and ATM to add support for readonly transactions. I feel
> > this could be a really useful addition.
>
> > Basically, I've added a ReadOnly parameter to the
> > TransactionAttribute. This flag is then passed to the ResourceAdapter
> > in NHibernate intergration which temporarily sets the FlushMode to
> > FlushMode.Never for the duration of the transaction.
>
> > Is this something you would be interested in reviewing? If so, would
> > you like some patches?
>
> > regards,
> > Jordan.
>
> > --
> > You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
> > To post to this group, send email to castle-pro...@googlegroups.com.
> > To unsubscribe from this group, send email to castle-project-d...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/castle-project-devel?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
> To post to this group, send email to castle-pro...@googlegroups.com.
> To unsubscribe from this group, send email to castle-project-d...@googlegroups.com.
> For more options, visit this group athttp://groups.google.com/group/castle-project-devel?hl=en.

hammett

unread,
May 4, 2010, 11:18:11 PM5/4/10
to castle-pro...@googlegroups.com
I see. Given that they are sharing the session, the dirty fields will
still be persisted.
I guess that's a work around while we dont have transactional memory :-)

On Tue, May 4, 2010 at 9:27 AM, Jordan <augustu...@yahoo.co.uk> wrote:
> - Transactional service 1 is called and makes some modifications to an
> entity which fail validiation, so the transaction is rolled back.
> - Transaction service 2 is called by the web front end to retrieve
> some data to display to the user in the next screen.


--
Cheers,
hammett
http://hammett.castleproject.org/

Jordan

unread,
May 5, 2010, 4:50:26 AM5/5/10
to Castle Project Development List
heh, yeah I guess so!

Jordan.

On May 5, 4:18 am, hammett <hamm...@gmail.com> wrote:
> I see. Given that they are sharing the session, the dirty fields will
> still be persisted.
> I guess that's a work around while we dont have transactional memory :-)
>
> On Tue, May 4, 2010 at 9:27 AM, Jordan <augustusgor...@yahoo.co.uk> wrote:
> > - Transactional service 1 is called and makes some modifications to an
> > entity which fail validiation, so the transaction is rolled back.
> > - Transaction service 2 is called by the web front end to retrieve
> > some data to display to the user in the next screen.
>
> --
> Cheers,
> hammetthttp://hammett.castleproject.org/

Jordan

unread,
May 5, 2010, 9:58:19 AM5/5/10
to Castle Project Development List
Hello again,

Just sent the pull requests... but have noticed that my visual studio
was set to spaces instead of tabs, sorry!

Jordan.

Krzysztof Koźmic

unread,
May 5, 2010, 11:09:56 AM5/5/10
to castle-pro...@googlegroups.com
NP,

you can always fix it :)

John Simons

unread,
May 7, 2010, 7:17:15 PM5/7/10
to Castle Project Development List
Hi Jordan,

Happy to merge your changes to our master repository, but I noticed
you don't have any tests :(
Also, I've just done a large commit to merge Henrik's fork (http://
github.com/castleproject/Castle.Services.Transaction/commit/
de7df0fdd5d5adabbb7c65f46d1ad6efdb3c0bf1 and
http://github.com/castleproject/Castle.Facilities.AutomaticTransactionManagement/commit/4a39e0a46780eb9a7ec9b1f5c5812f8af4165cae),
and that has changed a few things, are you able to update your fork so
we can merge it without many conflicts?

Cheers
John

Jordan

unread,
May 10, 2010, 10:05:46 AM5/10/10
to Castle Project Development List
inline

> Happy to merge your changes to our master repository, but I noticed
> you don't have any tests :(

Ok thanks, I'll deal with that...

> Also, I've just done a large commit to merge Henrik's fork (http://
> github.com/castleproject/Castle.Services.Transaction/commit/
> de7df0fdd5d5adabbb7c65f46d1ad6efdb3c0bf1 andhttp://github.com/castleproject/Castle.Facilities.AutomaticTransactio...),
> and that has changed a few things, are you able to update your fork so
> we can merge it without many conflicts?

Would it be easiest for me to just delete my fork and create a new one
from the latest code?

cheers,
Reply all
Reply to author
Forward
0 new messages