If you set the TransactionManager type to EXTERNAL, then the start/commit/end will have no effect.  Or if you set it to JTA, then it will attempt to participate in the global transaction if possible.

Cheers,
Clinton

On 10/18/05, Gary Barlow <[EMAIL PROTECTED]> wrote:
Thanks Clinton,

Yep that has the desired effect, however, I'm running this in the EJB layer
with container managed transactions. Do you know how startTransaction() /
endTransaction() behave in this situation?


Gary

>
>You need to wrap the batch in a transaction....
>
>try {
>sqlMapClient.startTransaction();
>sqlMapClient.startBatch();
>...
>sqlMapClient.executeBatch ();
>sqlMapClient.commitTransaction();
>} finally {
>sqlMapClient.endTransaction
>}
>
>Clinton
>
>On 10/18/05, Gary Barlow <[EMAIL PROTECTED] > wrote:
> >
> > Hi there, I'm using v2.1.5 with spring and attempting to use batched
> > statements but it doesn't seem to batch! The code below functions fine
>but
> > when testing for duplicate inserts I noticed if failed on the insert
> > rather
> > than the executeBatch() statement. This suggests it's not batching! Also
> > noticed that the count returned from execute batch is always zero.
> >
> > Have I coded this corrrectly? Are there any know issues?
> >
> > public class SqlMapParameterDao extends SqlMapClientDaoSupport
>implements
> > ParameterDao {
> >
> > ............................
> >
> > public void saveParameterValues(final Parameter parameter, final List
> > vals)
> > throws IntegrityViolationException {
> > try {
> >
> > this.getSqlMapClient().startBatch();
> > for (int i = 0; i < pvals.size(); i++) {
> > ParameterValue parameterValue = (ParameterValue) pvals.get(i);
> > this.getSqlMapClient().insert("insertParameterValue", new
> > ParameterValueCriteria(parameterValue.getParameter().getId(),
> > parameterValue));
> > }
> > int count = this.getSqlMapClient().executeBatch();
> > } catch (SQLException e) {
> > throw new IntegrityViolationException(e.getMessage());
> > }
> > }
> >
> >
> >



Reply via email to