Closed GoogleCodeExporter closed 9 years ago
Turned out it was a problem with mybatis-guice (ErrorContext implictly created
in ConfigurationProvider and never reset).
See the attached patch (also posted in the forum thread discussion with Simo).
(Patch also contains a fix for the other mentioned problem with custom
TypeHandlers not working dues to wrong order of calls to @Inject setters.)
Original comment by stephen....@gmail.com
on 15 Sep 2010 at 12:26
Attachments:
Original comment by simone.t...@gmail.com
on 15 Sep 2010 at 7:41
Your patch has been sucefully applied, thanks Stephen.
I added trivial modifications to your original code since I'm not a very big
fun of classes declared on-the-fly, BTW I maintained your original logic.
I hope you'll enjoy seeing your nome on the maven pom.
Margin note: the RC2 will be released today so you can upgrade it in your
system.
Original comment by simone.t...@gmail.com
on 15 Sep 2010 at 8:18
I am observing the same issue with a mybatis-spring webapp,
using mybatis 3.0.3, mybatis-spring-1.0.0-RC3.
The culprit is SqlSessionFactoryBean.buildSqlSessionFactory() (invoked from
SqlSessionFactoryBean.afterPropertiesSet()).
The bean is defined as following:
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSourceData" />
<property name="configLocation" value="/WEB-INF/sqlmap-config.xml" />
</bean>
When buildSqlSessionFactory() parses the config file with XMLConfigBuilder, the
builder creates the ErrorContext. The ErrorContext.reset() method is never
called.
If I specified the "mapperLocations" property to SqlSessionFactoryBean, I'd
expect to observe the same behavior caused by XMLMapperBuilder.
My workaround is to subclass SqlSessionFactoryBean and reset the ErrorContext
when afterPropertiesSet() call returns:
public class CustomSqlSessionFactoryBean extends SqlSessionFactoryBean {
@Override
public void afterPropertiesSet() throws Exception {
try {
super.afterPropertiesSet();
} finally {
ErrorContext.instance().reset();
}
}
}
Original comment by knst.kol...@gmail.com
on 2 Dec 2010 at 6:45
Sorry, I have just seen this issue.
Having a look at it I would say that normally the call to
sqlSessionFactoryBuilder.build() should reset ErrorContext but certainly if an
exception is thrown in the middle of the method it wont be called.
Anyway it is better to close it explicitly.
Fixed in r3468. Please give it a try.
Original comment by eduardo.macarron
on 31 Dec 2010 at 12:03
Original comment by eduardo.macarron
on 5 Apr 2012 at 6:27
Original issue reported on code.google.com by
stephen....@gmail.com
on 14 Sep 2010 at 9:12Attachments: