Created
September 28, 2016 19:23
-
-
Save MirkoRossini/647e4e8f4aefd913bcd664fce75b8685 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mirkorossini.transactionaltest.services; | |
import com.mirkorossini.transactionaltest.mappers.DummyMapper; | |
import org.apache.ibatis.session.SqlSessionManager; | |
import org.mybatis.guice.transactional.Transactional; | |
import javax.inject.Inject; | |
public class DummyService implements DummyServiceInt { | |
private final DummyMapper dummyMapper; | |
private final SqlSessionManager sqlSessionManager; | |
@Inject | |
public DummyService(final DummyMapper dummyMapper, | |
final SqlSessionManager sqlSessionManager) { | |
this.dummyMapper = dummyMapper; | |
this.sqlSessionManager = sqlSessionManager; | |
} | |
@Override | |
@Transactional | |
public void insertValue(int value) { | |
assert sqlSessionManager.isManagedSessionStarted(); | |
} | |
public void insertValueCallingPublicMethod(int value) { | |
insertValue(value); | |
} | |
public void insertValueCallingPrivateMethod(int value) { | |
insertValuePrivate(value); | |
} | |
@Transactional | |
private void insertValuePrivate(int value) { | |
assert sqlSessionManager.isManagedSessionStarted(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment