in addition to these comments i would also read chapter 7 on transactions as 
spring transaction demarcation strategies are very useful.. The spring 
reference manual is available at their website. 

-----Original Message-----
From: John Hurst [mailto:[EMAIL PROTECTED]
Sent: Thu 8/4/2005 9:24 PM
To: [email protected]
Subject: RE: Ibatis and Spring Framework
 
Hi,

I use iBATIS with Spring.  In fact I learned about iBATIS via Spring; I
think the two together work very well.

In addition to Richard's comments, I would add:

  - Common configuration mechanism across your whole project, and separation
of configuration from your code.

With Spring, your DAOs can be provided with what they need via dependency
injection.  You put for example a setDataSource() in your class, and you can
configure Spring to wire up the DataSource at runtime.  This is incredibly
powerful.

  - The SqlMapClientDaoSupport provides a great base class for DAOs to make
use of Spring facilities, such as transparent transaction control.  It
already has the setters necessary to configure DataSource or SqlMapClient.
It also provides the SqlMapClientTemplate, a smart way to do operations
requiring resources.

For example the iBATIS developer guide example

public void updateItemDescription(String itemId, String newDescription)
throws SQLException {
  try {
    sqlMap.startTransaction();
    Item item = (Item) sqlMap.queryForObject ("getItem", itemId);
    item.setDescription (newDescription);
    sqlMap.update ("updateItem", item);
    sqlMap.commitTransaction ();
  } finally {
    sqlMap.endTransaction ();
  }
}

Could look like this with Spring:

public void updateDescription(String itemId, String newDescription) {
  Item item = (Item) getSqlMapClientTemplate().queryForObject("getItem",
itemId);
  Item.setDescription(newDescription);
  getSqlMapClientTemplate().update("updateItem", item);
}

Many fully transactional DAO methods become one-liners with Spring.

The iBATIS API is very clean; the advantage of the Spring XxxTemplate
classes becomes all the more clearer with an API like raw JDBC.

Regards

John Hurst


> -----Original Message-----
> From: rich oates [mailto:[EMAIL PROTECTED]
> Sent: Friday, 5 August 2005 07:18
> To: [email protected]
> Subject: Re: Ibatis and Spring Framework
> 
> The Spring JDBC wrapper offers at least the following:
> 
> - a further abstraction away from iBatis (which is useful if you wish
> to change the underlying persistence framework in the future)
> 
> - common data access exceptions (i.e. the iBatis exceptions are mapped
> to spring exceptions. Again, useful if you want to reduce dependency
> on iBatis).
> 
> There are other benefits, especially when the rest of what Spring
> offers is taken into account, e.g. transparent transaction handling.
> 
> I recommend having a look at chapter 11 of the Spring reference
> documentation.
> 
> regards
> richard




This e-mail and any attachment is for authorised use by the intended 
recipient(s) only. It may contain proprietary material, confidential 
information and/or be subject to legal privilege. It should not be copied, 
disclosed to, retained or used by, any other party. If you are not an intended 
recipient then please promptly delete this e-mail and any attachment and all 
copies and inform the sender. Thank you.

<<inline: winmail.dat>>

Reply via email to