ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Batch not batching!
Date Tue, 18 Oct 2005 18:00:11 GMT
Yes. This allows you to code in one consistent way, whether you're in a
global or a local transaction scope.

Cheers,
Clinton

On 10/18/05, Gary Barlow <garybarlow@hotmail.com> wrote:
>
> I'm running in WebLogic and use it's pooled DataSource rather than an
> explicit TransactionManager configuration. I guess that amounts to the
> same
> thing as EXTERNAL?
>
> Are you saying that calling start/end transaction is necessary for the
> ibatis batch statement to work but will have no effect on the transaction
> which is managed by the container?
>
> Thanks
>
> Gary
>
> >
> >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 <garybarlow@hotmail.com> 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 <garybarlow@hotmail.com> 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());
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >
>
>
>

Mime
View raw message