ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Poitras Christian" <Christian.Poit...@ircm.qc.ca>
Subject RE: iBATIS, Spring, and transactions...
Date Tue, 10 Apr 2007 17:10:08 GMT
First, you can still use BeanAction with Spring DAO.
The most simple solution to set your static variable is to get it from
First get the SpringContext and do the following.
private static final TheService instance =
The way you can get SpringContext is relaitve on how you initialize it.
This is a code sample of how you can access it if you use
 * Listen for Spring initialization.
 * @author poitrac
public class SpringInit implements ServletContextListener {
     * Spring's WebApplicationContext.
    private static WebApplicationContext springContext;
    public SpringInit() {
    /* (non-Javadoc)
     * @see
    public void contextInitialized(ServletContextEvent event) {
        springContext =
    /* (non-Javadoc)
     * @see
    public void contextDestroyed(ServletContextEvent event) {
     * Returns Spring's WebApplicationContext.
     * @return Spring's WebApplicationContext.
    public static ApplicationContext getApplicationContext() {
        return springContext;


From: Meindert [mailto:meindert@pastelebusiness.com] 
Sent: Tuesday, 10 April 2007 12:30
To: user-java@ibatis.apache.org
Subject: RE: iBATIS, Spring, and transactions...

I'm busy converting and went to the site

What is quite a clear explanation :-)


I'm converting a project that is based on the jpetstore, what is using
org.apache.struts.beanaction.BeanAction in my struts-config.xml

The above mentioned site has got a different approach.

My question is;

a) can I still use org.apache.struts.beanaction.BeanAction? I only want
to change the DAO to Spring DAO because IBATIS DAO is depreciated

and if so

b) The BeanAction class is using

private static final TheService theService = TheService.getInstance();

to connect with the service object, what created itself static;

private static final TheService instance = new TheService();


How do I get a instance from the spring created service object?

My service object get's created by spring using the following config in

<bean id=" theService " class="com.service.TheService ">

        <constructor-arg index="0" ref="theDao"/>


And code;

public TheService (TheDao theDao){

      this.theDao = theDao;



Kind Regards





-----Original Message-----
From: Poitras Christian [mailto:Christian.Poitras@ircm.qc.ca] 
Sent: 10 April 2007 04:25 PM
To: user-java@ibatis.apache.org; lmeadors@apache.org
Subject: RE: iBATIS, Spring, and transactions...


That would be a great idea!

It's always welcome to see some code to show each steps. My app is

already to big to use it direclty as an example... 




I'll check if I can provide you with my smaller app (contains only 2

actions, but it does not have any transaction).

I'll just add the insert/updates I used at first to fill database.


-----Original Message-----

From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf

Of Larry Meadors

Sent: Tuesday, 10 April 2007 10:16

To: user-java@ibatis.apache.org

Subject: Re: iBATIS, Spring, and transactions...


That would be AWESOME, if you want, I can help with proofing, etc.


Maybe someone else would be willing to provide a *simple* iBATIS DAO

sample application that we could convert and then document the process.





On 4/10/07, Poitras Christian <Christian.Poitras@ircm.qc.ca> wrote:

> I have to say that it would be really nice to have an "how to" for 

> passing from iBATIS DAO to Spring DAO...

> I made a french document about that question. I could transalte it to 

> english in the next weeks and put it on the wiki...

View raw message