ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meindert" <meind...@pastelebusiness.com>
Subject RE: converting iBATIS framework DAOs to the Spring Framework
Date Mon, 16 Apr 2007 09:35:06 GMT
Hi Christian,

 

Had a closer look at it and the logical reason the proxy could not be
generated is the fact the service classes (in JPetstore) don't use an
interface.

I would like to keep it that way, because the reason's I heard for giving it
an interface are not convincing (reasons like 'it is the right thing to do',
'easy interchange of implementations') .

So (for now) I would say that it is not possible to have a transaction in
the business logic (if the business logic doesn't implement a interface).

 

Kind Regards

 Meindert

 

  _____  

From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca] 
Sent: 13 April 2007 06:08 PM
To: user-java@ibatis.apache.org
Subject: RE: converting iBATIS framework DAOs to the Spring Framework

 

Download CGLIB (at least version 2.1.3)

http://sourceforge.net/project/showfiles.php?group_id=56933

 

Christian

 

  _____  

From: Meindert [mailto:meindert@pastelebusiness.com] 
Sent: Friday, 13 April 2007 12:03
To: user-java@ibatis.apache.org; lmeadors@apache.org
Subject: RE: converting iBATIS framework DAOs to the Spring Framework

Hi All,

 

I had a look at spring transactions and can get the annotation working for
the dao layer but not for the service layer?

 

This is the xml I added in the spring config file to enable spring
annotations (Java1.5+ required), 

<!-- TRANSACTIONS -->

    <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

        <property name="dataSource">

            <ref bean="dataSource"/>

        </property>

    </bean>

    

    <bean
class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCr
eator"/>

    

    <bean
class="org.springframework.transaction.interceptor.TransactionAttributeSourc
eAdvisor">

        <property name="transactionInterceptor" ref="txInterceptor"/>

    </bean>

    

    <bean id="txInterceptor"
class="org.springframework.transaction.interceptor.TransactionInterceptor">

        <property name="transactionManager" ref="txManager"/>

        <property name="transactionAttributeSource">

            <bean
class="org.springframework.transaction.annotation.AnnotationTransactionAttri
buteSource"/>

        </property>

    </bean>

 

Step 2, Tested it on the dao layer by modifying updateAccount

@Transactional

public void updateAccount(Account account) {

    update("updateAccount", account);

    int i = 5/0;  //division by zero, expect rollback of account changes

    update("updateProfile", account);

 

 }

This works! But if I move the annotation to the service layer like this

@Transactional

public void updateAccount(Account account) {

     accountDao.updateAccount(account);

}

I get

org.springframework.aop.framework.AopConfigException: Cannot proxy target
class because CGLIB2 is not available. Add CGLIB to the class path or
specify proxy interfaces.

 

Kind Regards

 Meindert

 

-----Original Message-----
From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf Of
Larry Meadors
Sent: 12 April 2007 04:14 PM
To: user-java@ibatis.apache.org
Subject: Re: converting iBATIS framework DAOs to the Spring Framework

 

Thanks a TON for doing this, it's really appreciated!

 

Here is the WIKI Page: http://tinyurl.com/ysvjw5

 

I just converted it to WIKI format and corrected some simple stuff.

 

I was curious why if we are starting with jpetshop5, why not use the

hsqldb stuff that is there?

 

Also, I'd suggest that we use constructor injection instead of setter

injection - that way, we only need to remove the default constructors

from the service classes (eg., public AccountService() {...}, and the

related imports. It also prevents people from replacing the dao

instances (well, not entirely, but they have to do a bit more work).

 

Larry


Mime
View raw message