ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniel Guido" <dgu...@gmail.com>
Subject beginner spring+ibatis help
Date Fri, 27 Jun 2008 20:50:08 GMT
I'm a student and my grasp of JSP/J2EE, iBatis, and Spring is a little
iffy. I'm attempting to learn all of them as part of a project and I'd
appreciate any help you could offer me (and to save time, yes, I've
read the developer's guide pdf).

I followed the Spring tutorial to create their little inventory
management demo-app. It works fine with JDBC and HSQL and I mostly
understand what's going on. The URL for that tutorial is here:
http://static.springframework.org/docs/Spring-MVC-step-by-step/

Now I'm trying to replace the JDBC DAO with an iBatis DAO. I think
I've got everything put together correctly, but my ProductDao (the
parent class to my SqlMapProductDao) has a method: public
List<Product> getProductList(); It was created in this step of the
tutorial: http://static.springframework.org/docs/Spring-MVC-step-by-step/part5.html#step5.4

How do I create an equivalent function in the SqlMapProductDao? I made
a sql map that looks like this (my columns and properties match, no
need for result maps):
<select id="selectAllProducts" resultMap="ProductResult">
    select * from products
</select>

The following is _completely_ wrong but at least shows what I'd like it to do:


    public List<Product> getProductList() throws DataAccessException {
      logger.info("Getting products! (iBatis)");

      this.sqlMapClient.startTransaction();
      try {
          List<Product> allProducts =
this.sqlMapClient.queryForList("selectAllProducts");
          return allProducts;
      }
      catch (SQLException ex) {}
      this.sqlMapClient.commitTransaction();
    }


based off this:
http://static.springframework.org/spring/docs/2.5.x/reference/orm.html#orm-ibatis-straight

Can anyone help? I can post more of the source I'm working with if you
think it will help. Thanks.


--
Dan Guido

Mime
View raw message