JTA Transaction doesn't flush 2nd level cache

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

JTA Transaction doesn't flush 2nd level cache

Humberto Ferreira da Luz Jr.
Hi, I just began using MyBatis since last week.

It has been working great, but I found a problem. I enabled 2nd level cache and I'm using stateless EJBs to manage my transactions. However, this way my 2nd level cache is never flushed after updates.

I also tried the javax.transaction.Transactional with no luck. The only way I managed to flush the cache was invoking sqlSession.commit(), but I don't think this is the right way, since I'm using xa-datasources and I have to manage transactions using multiple datasources.

Anyone 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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: JTA Transaction doesn't flush 2nd level cache

Humberto Ferreira da Luz Jr.
My transactionManager is set as MANAGED in mybatis-config.xml, by the way.

--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: JTA Transaction doesn't flush 2nd level cache

Guy Rouillier-2
In reply to this post by Humberto Ferreira da Luz Jr.
Have you read the MyBatis User's Guide regarding transactionManager?

"MANAGED – This configuration simply does almost nothing. It never commits, or rolls back
a connection. Instead, it lets the container manage the full lifecycle of the transaction (e.g.
a JEE Application Server context)."

Have you properly configured your app server to handle transactions?  I'm guessing you are concluding that "my 2nd level cache is never flushed after updates." by your updates not appearing in the database.  Correct?  The fact that you see your updates by issuing an explicit sqlSession.commit() would seem to indicate your app server is not committing transactions as you expect.

--
Guy Rouillier

------ Original Message ------
From: "Humberto Ferreira da Luz Jr." <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 8/9/2018 2:30:06 PM
Subject: JTA Transaction doesn't flush 2nd level cache

Hi, I just began using MyBatis since last week.

It has been working great, but I found a problem. I enabled 2nd level cache and I'm using stateless EJBs to manage my transactions. However, this way my 2nd level cache is never flushed after updates.

I also tried the javax.transaction.Transactional with no luck. The only way I managed to flush the cache was invoking sqlSession.commit(), but I don't think this is the right way, since I'm using xa-datasources and I have to manage transactions using multiple datasources.

Anyone 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].
For more options, visit https://groups.google.com/d/optout.

--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: JTA Transaction doesn't flush 2nd level cache

Humberto Ferreira da Luz Jr.
I Guy, I did read the User Guide regarding transaction manager. I know that when it's set as MANAGED, the transaction is managed by the container, but I expected the cache would still be flushed on updates/inserts.

The updates are commited correctly to the database by the container, if I restart my JBoss EAP server, the cache is cleared and the change is loaded correctly by select. However, if I make another change through update, the cache isn't flushed.

I managed to solve the issue by not using stateless EJBs or standard Transactional annotation, but instead the mybatis-cdi transactional annotation, with the JTA interceptor configured.

Em sexta-feira, 10 de agosto de 2018 01:00:42 UTC-3, Guy Rouillier escreveu:
Have you read the MyBatis User's Guide regarding transactionManager?

"MANAGED – This configuration simply does almost nothing. It never commits, or rolls back
a connection. Instead, it lets the container manage the full lifecycle of the transaction (e.g.
a JEE Application Server context)."

Have you properly configured your app server to handle transactions?  I'm guessing you are concluding that "my 2nd level cache is never flushed after updates." by your updates not appearing in the database.  Correct?  The fact that you see your updates by issuing an explicit sqlSession.commit() would seem to indicate your app server is not committing transactions as you expect.

--
Guy Rouillier

------ Original Message ------
From: "Humberto Ferreira da Luz Jr." <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="wjFfyW0fAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">hflu...@...>
To: "mybatis-user" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="wjFfyW0fAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...>
Sent: 8/9/2018 2:30:06 PM
Subject: JTA Transaction doesn't flush 2nd level cache

Hi, I just began using MyBatis since last week.

It has been working great, but I found a problem. I enabled 2nd level cache and I'm using stateless EJBs to manage my transactions. However, this way my 2nd level cache is never flushed after updates.

I also tried the javax.transaction.Transactional with no luck. The only way I managed to flush the cache was invoking sqlSession.commit(), but I don't think this is the right way, since I'm using xa-datasources and I have to manage transactions using multiple datasources.

Anyone 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="wjFfyW0fAQAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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].
For more options, visit https://groups.google.com/d/optout.