problems with mybatis transaction using ejb3 on jboss 6

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problems with mybatis transaction using ejb3 on jboss 6

Mauricio Amorim
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 ?

















--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/6fba2089-f7e2-4a5a-a729-def6564a5566%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: problems with mybatis transaction using ejb3 on jboss 6

Mauricio Amorim
Hi, mybatis users

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

Thank you for all 


Em terça-feira, 24 de março de 2020 09:02:26 UTC-3, Mauricio Amorim escreveu:
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 ?

















--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/f0d3d9b6-bd3c-48ae-a2c5-16d1a6165297%40googlegroups.com.