problems with mybatis transaction using ejb3 on jboss 6

9 views
Skip to first unread message

Mauricio Amorim

unread,
Mar 24, 2020, 8:02:26 AM3/24/20
to mybatis-user
HI, group

I use the following configuration in mybatis:

<environments default="development">
<environment id="development">
<transactionManager type="MANAGED">
</transactionManager>  
<dataSource type="JNDI">
<property name ="data_source" value="java:/CBILLDS"/>
</dataSource>   
</environment>
</environments>


below a peace of my ejb code:

public class OnlendingMassServiceBean implements OnlendingMassService {


@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class OnlendingMassServiceBean implements OnlendingMassService {
    public void insertOnlendingMassFileRecord(OnlendingMassFileRecord onlendingMassFileRecord) {
        OnlendingMassDAOMyBatis.getInstance().insertOnlendingMassFileRecord(onlendingMassFileRecord);
    }
}

public class OnlendingMassDAOMyBatis implements Serializable, OnlendingMassMapper {
    @Override
    public void insertOnlendingMassFileRecord(OnlendingMassFileRecord onlendingMassFileRecord) {
        SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession();
        try {
            OnlendingMassMapper mapper = sqlSession.getMapper(OnlendingMassMapper.class);
            mapper.insertOnlendingMassFileRecord(onlendingMassFileRecord);
        } finally {
            sqlSession.flushStatements();
            sqlSession.close();
        }
    }
}


if my method is annotted as @TransactionAttribute(TransactionAttributeType.REQUIRESNEW) the persisted entity is  commited in database OK


But with @TransactionAttribute(TransactionAttributeType.REQUIRED) it fails because of the constraint between the involved tables.
If i drop my oracle constraint it function. in some cases i have to use DEFERRABLE INITIALLY DEFERRED but not always function

i need to use a mybatis-cdi for provide a transactional for my required methods  ? or my ibatis configuration is wrong ?

Someone can help me ?

















Mauricio Amorim

unread,
Mar 24, 2020, 9:44:02 AM3/24/20
to mybatis-user
Hi, mybatis users

i did a mistake on my database constraint creation. i'm sorry.
I guess it function now.

Thank you for all 
Reply all
Reply to author
Forward
0 new messages