You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by smallufo <sm...@gmail.com> on 2010/12/18 16:58:52 UTC
How to programmatically get PlatformTransactionManager of a DAO ?
I am developing a generic CRUD app , that can edit any Spring/JPA entities
with a AbstractDao pattern's implementation , such as UserDaoImpl ,
ForumDaoImpl ...etc
In my wicket page : I have to use @SpringBean to identify which
PlatformTransactionManager to use , such as :
@SpringBean(name="transactionManagerUser")
private PlatformTransactionManager transactionManagerUser;
private TransactionTemplate txTemplate;
public CrudPage(final PageParameters pps , final AbstractDao<T> dao)
{
super(pps);
txTemplate= new TransactionTemplate(transactionManagerUser);
}
The problem is , these DAOs are using different transaction managers , such
astransactionManagerUser , transactionManagerForum ...etc.
I cannot hard-code these txManager's name in my code. I have to
programmatically get the dao's txManager . How to achieve that ?
Thanks a lot !
Environments : Spring 3.0.5 , Hibernate-3.6 , JPA2
Re: How to programmatically get PlatformTransactionManager of a DAO ?
Posted by Zilvinas Vilutis <ci...@gmail.com>.
why don't you expose a "getTxManagerUser" method in your AbstractDao class?
regards
Žilvinas Vilutis
Mobile: (+370) 652 38353
E-mail: cikasfm@gmail.com
On Sat, Dec 18, 2010 at 9:36 AM, smallufo <sm...@gmail.com> wrote:
> Thanks.
> but declarative txManagement add a lot of complexity to XMLs
> Is there any other option ?
>
>
> 2010/12/19 James Carman <ja...@carmanconsulting.com>
>
>> declarative transaction management
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: How to programmatically get PlatformTransactionManager of a DAO ?
Posted by James Carman <ja...@carmanconsulting.com>.
Use annotations
On Dec 18, 2010 11:37 AM, "smallufo" <sm...@gmail.com> wrote:
> Thanks.
> but declarative txManagement add a lot of complexity to XMLs
> Is there any other option ?
>
>
> 2010/12/19 James Carman <ja...@carmanconsulting.com>
>
>> declarative transaction management
Re: How to programmatically get PlatformTransactionManager of a DAO ?
Posted by smallufo <sm...@gmail.com>.
Thanks.
but declarative txManagement add a lot of complexity to XMLs
Is there any other option ?
2010/12/19 James Carman <ja...@carmanconsulting.com>
> declarative transaction management
Re: How to programmatically get PlatformTransactionManager of a DAO ?
Posted by James Carman <ja...@carmanconsulting.com>.
Use declarative transaction management instead
On Dec 18, 2010 10:59 AM, "smallufo" <sm...@gmail.com> wrote:
> I am developing a generic CRUD app , that can edit any Spring/JPA entities
> with a AbstractDao pattern's implementation , such as UserDaoImpl ,
> ForumDaoImpl ...etc
>
> In my wicket page : I have to use @SpringBean to identify which
> PlatformTransactionManager to use , such as :
>
> @SpringBean(name="transactionManagerUser")
> private PlatformTransactionManager transactionManagerUser;
> private TransactionTemplate txTemplate;
>
> public CrudPage(final PageParameters pps , final AbstractDao<T> dao)
> {
>
> super(pps);
>
> txTemplate= new TransactionTemplate(transactionManagerUser);
> }
>
> The problem is , these DAOs are using different transaction managers ,
such
> astransactionManagerUser , transactionManagerForum ...etc.
>
> I cannot hard-code these txManager's name in my code. I have to
> programmatically get the dao's txManager . How to achieve that ?
>
> Thanks a lot !
>
> Environments : Spring 3.0.5 , Hibernate-3.6 , JPA2