[ANNOUNCEMENT] mybatis-spring-1.0.0-RC3 released!

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[ANNOUNCEMENT] mybatis-spring-1.0.0-RC3 released!

Simone Tripodi
Hi all,
The mybatis-spring team is pleased to announce the
mybatis-spring-1.0.0-RC3 release!

For those that don't know yet what mybatis-spring is, we like to
define it as "An easy-to-use Spring3 bridge for MyBatis sql mapping
framework".

Changes in this version include:


Fixed Bugs:
o Avoid one Proxy creation when using injected mappers  Issue: 166.

Changes:
o The getSqlSessionTemplate() method in SqlSessionDaoSupport has been
replaced by getSqlSession().

The problem: Your code will no longer compile
The solution: change your code this way:
from:
return (User) getSqlSessionTemplate().selectOne("org.mybatis.spring.sample.mapper.UserMapper.getUser",
userId);
to:
return (User) getSqlSession().selectOne("org.mybatis.spring.sample.mapper.UserMapper.getUser",
userId);

o MapperFactoryBean has been moved from org.mybatis.spring package to
org.mybatis.spring.mapper.

The problem: Your spring application does not boot. A
IllegalStateException is thrown.
The solution: change your applicationContext.xml as follows:

<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="mapperInterface" value="your.mapper.interface" />
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

o org.mybatis.spring.MapperScannerPostProcessor has been moved to
org.mybatis.spring.mapper.MapperScannerConfigurer. @Mapper annotation
no longer exists.

The problem: Your code will no longer compile.
The solution:
Replace the @Mapper annotation in your beans with a @Component annotation and
configure your applicationContext.xml as follows:

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  <property name="basePackage" value="your.base.package" />
  <property name="annotationClass"
value="org.springframework.stereotype.Component" />
</bean>

o Mapper scanning should not rely on proprietary @Mapper annotation
Issue: 176.
o Add new selectMap methods to SqlSessionTemplate  Issue: 163.


Have fun!
- Simo, on behalf of mybatis-spring team


http://people.apache.org/~simonetripodi/
http://www.99soft.org/
Reply | Threaded
Open this post in threaded view
|

Re: mybatis-spring-1.0.0-RC3 released!

Bryan
I noticed that SqlSessionCallback is gone, and the execute() method is
gone from SqlSessionTemplate. I was using this to set the ExecutorType
to batch. What is the new approach to this with RC3?

On Nov 22, 10:13 am, Simone Tripodi <[hidden email]> wrote:

> Hi all,
> The mybatis-spring team is pleased to announce the
> mybatis-spring-1.0.0-RC3 release!
>
> For those that don't know yet what mybatis-spring is, we like to
> define it as "An easy-to-use Spring3 bridge for MyBatis sql mapping
> framework".
>
> Changes in this version include:
>
> Fixed Bugs:
> o Avoid one Proxy creation when using injected mappers  Issue: 166.
>
> Changes:
> o The getSqlSessionTemplate() method in SqlSessionDaoSupport has been
> replaced by getSqlSession().
>
> The problem: Your code will no longer compile
> The solution: change your code this way:
> from:
> return (User) getSqlSessionTemplate().selectOne("org.mybatis.spring.sample.mapper.UserMap per.getUser",
> userId);
> to:
> return (User) getSqlSession().selectOne("org.mybatis.spring.sample.mapper.UserMapper.getU ser",
> userId);
>
> o MapperFactoryBean has been moved from org.mybatis.spring package to
> org.mybatis.spring.mapper.
>
> The problem: Your spring application does not boot. A
> IllegalStateException is thrown.
> The solution: change your applicationContext.xml as follows:
>
> <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
>     <property name="mapperInterface" value="your.mapper.interface" />
>     <property name="sqlSessionFactory" ref="sqlSessionFactory" />
> </bean>
>
> o org.mybatis.spring.MapperScannerPostProcessor has been moved to
> org.mybatis.spring.mapper.MapperScannerConfigurer. @Mapper annotation
> no longer exists.
>
> The problem: Your code will no longer compile.
> The solution:
> Replace the @Mapper annotation in your beans with a @Component annotation and
> configure your applicationContext.xml as follows:
>
> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
>   <property name="basePackage" value="your.base.package" />
>   <property name="annotationClass"
> value="org.springframework.stereotype.Component" />
> </bean>
>
> o Mapper scanning should not rely on proprietary @Mapper annotation
> Issue: 176.
> o Add new selectMap methods to SqlSessionTemplate  Issue: 163.
>
> Have fun!
> - Simo, on behalf of mybatis-spring team
>
> http://people.apache.org/~simonetripodi/http://www.99soft.org/
Reply | Threaded
Open this post in threaded view
|

Re: mybatis-spring-1.0.0-RC3 released!

Eduardo Macarron
Hi Bryan, you have to construct a new SqlSessionTemplate with a Batch
executor or better inject it. Have a look at page 8. You have also a
batch sample in the last chapter.


On 22 nov, 20:31, Bryan <[hidden email]> wrote:

> I noticed that SqlSessionCallback is gone, and the execute() method is
> gone from SqlSessionTemplate. I was using this to set the ExecutorType
> to batch. What is the new approach to this with RC3?
>
> On Nov 22, 10:13 am, Simone Tripodi <[hidden email]> wrote:
>
>
>
>
>
>
>
> > Hi all,
> > The mybatis-spring team is pleased to announce the
> > mybatis-spring-1.0.0-RC3 release!
>
> > For those that don't know yet what mybatis-spring is, we like to
> > define it as "An easy-to-use Spring3 bridge for MyBatis sql mapping
> > framework".
>
> > Changes in this version include:
>
> > Fixed Bugs:
> > o Avoid one Proxy creation when using injected mappers  Issue: 166.
>
> > Changes:
> > o The getSqlSessionTemplate() method in SqlSessionDaoSupport has been
> > replaced by getSqlSession().
>
> > The problem: Your code will no longer compile
> > The solution: change your code this way:
> > from:
> > return (User) getSqlSessionTemplate().selectOne("org.mybatis.spring.sample.mapper.UserMap per.getUser",
> > userId);
> > to:
> > return (User) getSqlSession().selectOne("org.mybatis.spring.sample.mapper.UserMapper.getU ser",
> > userId);
>
> > o MapperFactoryBean has been moved from org.mybatis.spring package to
> > org.mybatis.spring.mapper.
>
> > The problem: Your spring application does not boot. A
> > IllegalStateException is thrown.
> > The solution: change your applicationContext.xml as follows:
>
> > <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
> >     <property name="mapperInterface" value="your.mapper.interface" />
> >     <property name="sqlSessionFactory" ref="sqlSessionFactory" />
> > </bean>
>
> > o org.mybatis.spring.MapperScannerPostProcessor has been moved to
> > org.mybatis.spring.mapper.MapperScannerConfigurer. @Mapper annotation
> > no longer exists.
>
> > The problem: Your code will no longer compile.
> > The solution:
> > Replace the @Mapper annotation in your beans with a @Component annotation and
> > configure your applicationContext.xml as follows:
>
> > <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
> >   <property name="basePackage" value="your.base.package" />
> >   <property name="annotationClass"
> > value="org.springframework.stereotype.Component" />
> > </bean>
>
> > o Mapper scanning should not rely on proprietary @Mapper annotation
> > Issue: 176.
> > o Add new selectMap methods to SqlSessionTemplate  Issue: 163.
>
> > Have fun!
> > - Simo, on behalf of mybatis-spring team
>
> >http://people.apache.org/~simonetripodi/http://www.99soft.org/
Reply | Threaded
Open this post in threaded view
|

Re: mybatis-spring-1.0.0-RC3 released!

Bryan
There seems to be a problem with this new approach. If there is a
problem in the batch (e.g. a key violation), this exception is not
propagated up the stack, it is basically consumed by the transaction
manager. I'll enter a bug with more details.


On Nov 22, 12:44 pm, Eduardo <[hidden email]> wrote:

> Hi Bryan, you have to construct a new SqlSessionTemplate with a Batch
> executor or better inject it. Have a look at page 8. You have also a
> batch sample in the last chapter.
>
> On 22 nov, 20:31, Bryan <[hidden email]> wrote:
>
>
>
> > I noticed that SqlSessionCallback is gone, and the execute() method is
> > gone from SqlSessionTemplate. I was using this to set the ExecutorType
> > to batch. What is the new approach to this with RC3?
>
> > On Nov 22, 10:13 am, Simone Tripodi <[hidden email]> wrote:
>
> > > Hi all,
> > > The mybatis-spring team is pleased to announce the
> > > mybatis-spring-1.0.0-RC3 release!
>
> > > For those that don't know yet what mybatis-spring is, we like to
> > > define it as "An easy-to-use Spring3 bridge for MyBatis sql mapping
> > > framework".
>
> > > Changes in this version include:
>
> > > Fixed Bugs:
> > > o Avoid one Proxy creation when using injected mappers  Issue: 166.
>
> > > Changes:
> > > o The getSqlSessionTemplate() method in SqlSessionDaoSupport has been
> > > replaced by getSqlSession().
>
> > > The problem: Your code will no longer compile
> > > The solution: change your code this way:
> > > from:
> > > return (User) getSqlSessionTemplate().selectOne("org.mybatis.spring.sample.mapper.UserMap per.getUser",
> > > userId);
> > > to:
> > > return (User) getSqlSession().selectOne("org.mybatis.spring.sample.mapper.UserMapper.getU ser",
> > > userId);
>
> > > o MapperFactoryBean has been moved from org.mybatis.spring package to
> > > org.mybatis.spring.mapper.
>
> > > The problem: Your spring application does not boot. A
> > > IllegalStateException is thrown.
> > > The solution: change your applicationContext.xml as follows:
>
> > > <bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
> > >     <property name="mapperInterface" value="your.mapper.interface" />
> > >     <property name="sqlSessionFactory" ref="sqlSessionFactory" />
> > > </bean>
>
> > > o org.mybatis.spring.MapperScannerPostProcessor has been moved to
> > > org.mybatis.spring.mapper.MapperScannerConfigurer. @Mapper annotation
> > > no longer exists.
>
> > > The problem: Your code will no longer compile.
> > > The solution:
> > > Replace the @Mapper annotation in your beans with a @Component annotation and
> > > configure your applicationContext.xml as follows:
>
> > > <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
> > >   <property name="basePackage" value="your.base.package" />
> > >   <property name="annotationClass"
> > > value="org.springframework.stereotype.Component" />
> > > </bean>
>
> > > o Mapper scanning should not rely on proprietary @Mapper annotation
> > > Issue: 176.
> > > o Add new selectMap methods to SqlSessionTemplate  Issue: 163.
>
> > > Have fun!
> > > - Simo, on behalf of mybatis-spring team
>
> > >http://people.apache.org/~simonetripodi/http://www.99soft.org/
Reply | Threaded
Open this post in threaded view
|

Re: mybatis-spring-1.0.0-RC3 released!

Eduardo Macarron
You are comletely right Bryan. This is not a bug included in RC3, it
was also in RC2, but you found a workaround :)

The problem is really important because batches do not even work if
there is not any problem in the sentence.

This is caused by the commit order. When executor is not batch, all
statements are executed in the moment they are called. When a Spring
commit is started we first commit the connection and then the session.

But batches work different. Statements are buffered in BatchExecutor
so no statement is sent to the database until a SqlSession.commit() is
called. But as we commited the database first, no updates are done at
all.

I suppose you was calling a commit over the SqlSession but now commit
is a no-op. We did that because transaction should never be handled by
hand or data integrity problems may arise. We was in fact plannig to
throw an Exception because the user may believe that the commit/
rollback is working and it is not.

This issue is not going to be easy to solve. For the time being simply
add a dummy select as your last sentence. That will make MyBatis flush
its buffer and your code will work fine.

<select id="dummySelect" >
   select 1
</select>