You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Transactional (mybatis-cdi: org.mybatis.cdi.Transactional) annotation with rollbackOnly=true not rollbacking transactions inside a Weld / JUnit 5 test
#476
I'm not sure it's an issue of the Transactional annotation, it could be some missing configuration.
I have described the issue in detail on stackoverflow.
I'm pasting a copy here:
I expect this class UserMapperTest.java to run the test rollbacking the transaction (in this case for a simple insert, where the field email is unique, but the core of the problem is about the rollbacking):
And this is the SqlSessionFactoryProviderTest test implementation of the SqlSessionFactoryProvider:
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Produces;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.cdi.SessionFactoryProvider;
public class SqlSessionFactoryProviderTest implements SqlSessionFactoryProvider {
@Override
@TestSessionFactory
@Produces
@ApplicationScoped
@SessionFactoryProvider
public SqlSessionFactory produceFactory() {
return ConnectionFactory.getSqlSessionFactory();
}
}
I used to use a similar code with javax and junit 4 and worked fine. I'm trying to upgrade to jakarta and junit 5. It's possible that I'm missing something on the WeldInitiator? The userMapper is injected correctly and the query runs correctly, simply the transaction is not rollbacked.
The text was updated successfully, but these errors were encountered:
I'm not sure it's an issue of the
Transactional
annotation, it could be some missing configuration.I have described the issue in detail on stackoverflow.
I'm pasting a copy here:
I expect this class
UserMapperTest.java
to run the test rollbacking the transaction (in this case for a simple insert, where the field email is unique, but the core of the problem is about the rollbacking):The main
pom.xml
dependencies useful for this test are:with these
versions
:My
bean.xml
is this:This is the
TestSessionFactory
annotation:And this is the SqlSessionFactoryProviderTest test implementation of the
SqlSessionFactoryProvider
:I used to use a similar code with javax and junit 4 and worked fine. I'm trying to upgrade to jakarta and junit 5. It's possible that I'm missing something on the WeldInitiator? The
userMapper
is injected correctly and the query runs correctly, simply the transaction is not rollbacked.The text was updated successfully, but these errors were encountered: