users@javaee-spec.java.net

[javaee-spec users] [jsr342-experts] Re: transactional interceptors and lifecycle methods

From: Bill Shannon <bill.shannon_at_oracle.com>
Date: Fri, 15 Mar 2013 13:19:35 -0700

Kevin Sutter wrote on 03/15/13 12:27:
> Hi Bill,
> I could live with either option #1 or option #3 (#2 and 34 are non-starters, in
> my book). I am leaning towards option #1 since it's more declarative. You know
> exactly what transactional context will exist just by looking at the specific
> @PostConstruct or @PreDestroy method declarations. You don't have to know and
> understand the class level @Transactional value to know how the @PostContstruct
> or @PreDestroy will process.
>
> I think if we go with option #3, then the wording for the explanation needs a
> little beefing up. For example, the stated example for MANDATORY is very clear,
> but I'm fuzzy on what would happen if the value for @Transactional is either
> SUPPORTED or REQUIRES. Would both of these also behave as if REQUIRES_NEW was
> specified? Or, does some other rule come into effect? This is why I am leaning
> towards option #1.

They would behave the same way they do with regular methods, starting a
new transaction or operating in the context of any existing transaction.

Note that it's actually *possible* for there to be a transaction context
when a bean is created, although I would expect it to be rare.