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
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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 see your beans.xml is not jakarta one. Also have you looked at our tests? Its been quite some time since we moved to jakarta and don't recall that as an issue. I do see our tests are using transactional.
And still the @Transactional(rollbackOnly = true) (see class UserMapperTest.java above) is not working as I expected. Am I missing something else? Thank you very much for your patience.
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: