Mybatis with ejb on jboss 6

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

Mybatis with ejb on jboss 6

Mauricio Amorim Da Silva
Hi mybatis users...

I was trying use mybatis with ejb on jboss 6.

when i call a RequiresNew session bean method it's not commited after the methods finish.

someone already had the same problem ? thank you

Example:

----------------

ResubmissionServiceFactory.getResubmissionService().updateResubmissionsRequiresNew(
        ResubmissionTO.EXECUTING, ResubmissionBuilder.transform(invoicesToUpdateStatus), new Date());

-> here the data is not comited

----------------------------

/**
* @ejb.interface-method
* @ejb.transaction type="RequiresNew"
*/
@Override
public void updateResubmissionsRequiresNew(Integer state, Collection<ResubmissionTO> resubmissions,
        Date processDate) {
ResubmissionDAO.getInstance().updateResubmissions(state, resubmissions, processDate);
}


ResubmissionDAO:

@Override
public void updateResubmissions(Integer state, Collection<ResubmissionTO> resubmissions, Date processDate) {
SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(ExecutorType.BATCH);
try {
ResubmissionMapper mapper = sqlSession.getMapper(ResubmissionMapper.class);
for (ResubmissionTO resubmissionTO : resubmissions) {
mapper.updateStateErrorResubmission(resubmissionTO.getId(), state, resubmissionTO.getErrorMessage(),
        processDate, resubmissionTO.getLotEventId());
}
sqlSession.flushStatements();
sqlSession.commit();
} finally {
sqlSession.close();
}
}

--
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/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Mybatis with ejb on jboss 6

Guy Rouillier-2
See the MyBatis User Guide.  flushStatements is defined like this:

List<BatchResult> flushStatements()

Have you iterated over the List<BatchResult> to see the outcome of your statements?  I do not see that in the code below, so this code seems to assume that everything completes successfully.  Also, the default configuration for JBoss connections is they handle commits themselves.  I'm assuming you are using the JBoss connection pool.  Lots of assumptions here.  If you are using the JBoss connection pool, and the JBoss transaction manager, then you are not expected to issue your own commits.  Are you checking the JBoss logs to ensure the code is not generating errors?

--
Guy Rouillier

On 5/21/2019 5:46:47 PM, "Mauricio Amorim Da Silva" <[hidden email]> wrote:

Hi mybatis users...

I was trying use mybatis with ejb on jboss 6.

when i call a RequiresNew session bean method it's not commited after the methods finish.

someone already had the same problem ? thank you

Example:

----------------

ResubmissionServiceFactory.getResubmissionService().updateResubmissionsRequiresNew(
        ResubmissionTO.EXECUTING, ResubmissionBuilder.transform(invoicesToUpdateStatus), new Date());

-> here the data is not comited

----------------------------

/**
* @ejb.interface-method
* @ejb.transaction type="RequiresNew"
*/
@Override
public void updateResubmissionsRequiresNew(Integer state, Collection<ResubmissionTO> resubmissions,
        Date processDate) {
ResubmissionDAO.getInstance().updateResubmissions(state, resubmissions, processDate);
}


ResubmissionDAO:

@Override
public void updateResubmissions(Integer state, Collection<ResubmissionTO> resubmissions, Date processDate) {
SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(ExecutorType.BATCH);
try {
ResubmissionMapper mapper = sqlSession.getMapper(ResubmissionMapper.class);
for (ResubmissionTO resubmissionTO : resubmissions) {
mapper.updateStateErrorResubmission(resubmissionTO.getId(), state, resubmissionTO.getErrorMessage(),
        processDate, resubmissionTO.getLotEventId());
}
sqlSession.flushStatements();
sqlSession.commit();
} finally {
sqlSession.close();
}
}

--
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/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com.

--
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/emd2d331c3-c732-4e78-88b1-719cba03fd38%40asus.
Reply | Threaded
Open this post in threaded view
|

Re: Mybatis with ejb on jboss 6

Mauricio Amorim Da Silva
HI Guy Rouillier,

I was using jboss 6 connection pool and jboss transaction manager. 
My mybatis configurration is:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
  PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
  <typeAliases>
<typeAlias alias="resubmission" type="com.cpqd.billing.collection.model.event.ResubmissionTO"/>
  </typeAliases>  
  
  <environments default="development">
    <environment id="development">
<transactionManager type="MANAGED" />
<dataSource type="JNDI">
<property name ="data_source" value="java:/CBILLDS"/>
</dataSource>   
    </environment>
  </environments>
  
  <mappers>
    <mapper resource="com/cpqd/billing/collection/model/myibatis/collection-model-myibatis-resubmission-mapper.xml"/>
  </mappers>
</configuration>

I try remove the line sqlSession.commit() but the update is not commited on oracle database  

I did the same using old ibatis version and the updates are commited.

My old ibatis config is:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE sql-map-config
    PUBLIC "-//iBATIS.com//DTD SQL Map Config 1.0//EN"
    "http://www.ibatis.com/dtd/sql-map-config.dtd">

<!-- Always ensure to use the correct XML header as above! -->

<sql-map-config>

    <settings useGlobalTransactions="true"/>

    <sql-map resource="com/cpqd/billing/collection/model/ibatis/CollectionModel.xml" />

</sql-map-config>

Do you know if this line:

    <settings useGlobalTransactions="true"/>

has similar configuration on mybatis ?

Thank you.





Em quarta-feira, 22 de maio de 2019 03:06:00 UTC-3, Guy Rouillier escreveu:
See the MyBatis User Guide.  flushStatements is defined like this:

List<BatchResult> flushStatements()

Have you iterated over the List<BatchResult> to see the outcome of your statements?  I do not see that in the code below, so this code seems to assume that everything completes successfully.  Also, the default configuration for JBoss connections is they handle commits themselves.  I'm assuming you are using the JBoss connection pool.  Lots of assumptions here.  If you are using the JBoss connection pool, and the JBoss transaction manager, then you are not expected to issue your own commits.  Are you checking the JBoss logs to ensure the code is not generating errors?

--
Guy Rouillier

On 5/21/2019 5:46:47 PM, "Mauricio Amorim Da Silva" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RKvHONTjBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mas...@...> wrote:

Hi mybatis users...

I was trying use mybatis with ejb on jboss 6.

when i call a RequiresNew session bean method it's not commited after the methods finish.

someone already had the same problem ? thank you

Example:

----------------

ResubmissionServiceFactory.getResubmissionService().updateResubmissionsRequiresNew(
        ResubmissionTO.EXECUTING, ResubmissionBuilder.transform(invoicesToUpdateStatus), new Date());

-> here the data is not comited

----------------------------

/**
* @ejb.interface-method
* @ejb.transaction type="RequiresNew"
*/
@Override
public void updateResubmissionsRequiresNew(Integer state, Collection<ResubmissionTO> resubmissions,
        Date processDate) {
ResubmissionDAO.getInstance().updateResubmissions(state, resubmissions, processDate);
}


ResubmissionDAO:

@Override
public void updateResubmissions(Integer state, Collection<ResubmissionTO> resubmissions, Date processDate) {
SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(ExecutorType.BATCH);
try {
ResubmissionMapper mapper = sqlSession.getMapper(ResubmissionMapper.class);
for (ResubmissionTO resubmissionTO : resubmissions) {
mapper.updateStateErrorResubmission(resubmissionTO.getId(), state, resubmissionTO.getErrorMessage(),
        processDate, resubmissionTO.getLotEventId());
}
sqlSession.flushStatements();
sqlSession.commit();
} finally {
sqlSession.close();
}
}

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RKvHONTjBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com.

--
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/6a71a184-a23a-49f4-8c11-6a996df9c9a2%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Mybatis with ejb on jboss 6

Mauricio Amorim Da Silva
In reply to this post by Guy Rouillier-2
HI Guy Rouillier,

did you know if exists any difference between ejb2 and ejb3 transactions intercept on jboss that can caused this behavior?

thank you


Em quarta-feira, 22 de maio de 2019 03:06:00 UTC-3, Guy Rouillier escreveu:
See the MyBatis User Guide.  flushStatements is defined like this:

List<BatchResult> flushStatements()

Have you iterated over the List<BatchResult> to see the outcome of your statements?  I do not see that in the code below, so this code seems to assume that everything completes successfully.  Also, the default configuration for JBoss connections is they handle commits themselves.  I'm assuming you are using the JBoss connection pool.  Lots of assumptions here.  If you are using the JBoss connection pool, and the JBoss transaction manager, then you are not expected to issue your own commits.  Are you checking the JBoss logs to ensure the code is not generating errors?

--
Guy Rouillier

On 5/21/2019 5:46:47 PM, "Mauricio Amorim Da Silva" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="RKvHONTjBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mas...@...> wrote:

Hi mybatis users...

I was trying use mybatis with ejb on jboss 6.

when i call a RequiresNew session bean method it's not commited after the methods finish.

someone already had the same problem ? thank you

Example:

----------------

ResubmissionServiceFactory.getResubmissionService().updateResubmissionsRequiresNew(
        ResubmissionTO.EXECUTING, ResubmissionBuilder.transform(invoicesToUpdateStatus), new Date());

-> here the data is not comited

----------------------------

/**
* @ejb.interface-method
* @ejb.transaction type="RequiresNew"
*/
@Override
public void updateResubmissionsRequiresNew(Integer state, Collection<ResubmissionTO> resubmissions,
        Date processDate) {
ResubmissionDAO.getInstance().updateResubmissions(state, resubmissions, processDate);
}


ResubmissionDAO:

@Override
public void updateResubmissions(Integer state, Collection<ResubmissionTO> resubmissions, Date processDate) {
SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(ExecutorType.BATCH);
try {
ResubmissionMapper mapper = sqlSession.getMapper(ResubmissionMapper.class);
for (ResubmissionTO resubmissionTO : resubmissions) {
mapper.updateStateErrorResubmission(resubmissionTO.getId(), state, resubmissionTO.getErrorMessage(),
        processDate, resubmissionTO.getLotEventId());
}
sqlSession.flushStatements();
sqlSession.commit();
} finally {
sqlSession.close();
}
}

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="RKvHONTjBQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com.

--
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/f746a98b-d115-433c-a205-0867db92471f%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Mybatis with ejb on jboss 6

Mauricio Amorim Da Silva
Hi people of mybatis forum,

I tried newly using mybatis with jboss 6 and i use RequiresNew ejb methods running very well.

Thank you for the Help.

Follow configuration files and java files:

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


SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(ExecutorType.BATCH);
try {
ResubmissionMapper mapper = sqlSession.getMapper(ResubmissionMapper.class);
for (ResubmissionTO resubmissionTO : resubmissions) {
mapper.updateStateResubmission(resubmissionTO.getId(), resubmissionTO.getState(),
        resubmissionTO.getLotEventId(), resubmissionTO.getProcessDate());
}
} finally {
sqlSession.flushStatements();
sqlSession.close();
}



Em quinta-feira, 23 de maio de 2019 22:07:03 UTC-3, Mauricio Amorim Da Silva escreveu:
HI Guy Rouillier,

did you know if exists any difference between ejb2 and ejb3 transactions intercept on jboss that can caused this behavior?

thank you


Em quarta-feira, 22 de maio de 2019 03:06:00 UTC-3, Guy Rouillier escreveu:
See the MyBatis User Guide.  flushStatements is defined like this:

List<BatchResult> flushStatements()

Have you iterated over the List<BatchResult> to see the outcome of your statements?  I do not see that in the code below, so this code seems to assume that everything completes successfully.  Also, the default configuration for JBoss connections is they handle commits themselves.  I'm assuming you are using the JBoss connection pool.  Lots of assumptions here.  If you are using the JBoss connection pool, and the JBoss transaction manager, then you are not expected to issue your own commits.  Are you checking the JBoss logs to ensure the code is not generating errors?

--
Guy Rouillier

On 5/21/2019 5:46:47 PM, "Mauricio Amorim Da Silva" <[hidden email]> wrote:

Hi mybatis users...

I was trying use mybatis with ejb on jboss 6.

when i call a RequiresNew session bean method it's not commited after the methods finish.

someone already had the same problem ? thank you

Example:

----------------

ResubmissionServiceFactory.getResubmissionService().updateResubmissionsRequiresNew(
        ResubmissionTO.EXECUTING, ResubmissionBuilder.transform(invoicesToUpdateStatus), new Date());

-> here the data is not comited

----------------------------

/**
* @ejb.interface-method
* @ejb.transaction type="RequiresNew"
*/
@Override
public void updateResubmissionsRequiresNew(Integer state, Collection<ResubmissionTO> resubmissions,
        Date processDate) {
ResubmissionDAO.getInstance().updateResubmissions(state, resubmissions, processDate);
}


ResubmissionDAO:

@Override
public void updateResubmissions(Integer state, Collection<ResubmissionTO> resubmissions, Date processDate) {
SqlSession sqlSession = MyBatisUtil.getSqlSessionFactory().openSession(ExecutorType.BATCH);
try {
ResubmissionMapper mapper = sqlSession.getMapper(ResubmissionMapper.class);
for (ResubmissionTO resubmissionTO : resubmissions) {
mapper.updateStateErrorResubmission(resubmissionTO.getId(), state, resubmissionTO.getErrorMessage(),
        processDate, resubmissionTO.getLotEventId());
}
sqlSession.flushStatements();
sqlSession.commit();
} finally {
sqlSession.close();
}
}

--
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 <a href="https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/mybatis-user/e8bca5c9-9648-4400-9577-d98fff006435%40googlegroups.com.

--
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/d852f07c-9da5-4909-bee1-ff1b591b2c40%40googlegroups.com.