Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MyBatis integration with JBoss 7.1 web application

Had anybody attempted to use MyBatis as their persistence library for a JBoss 7.1 /Java EE6 application?

I'm wondering what are the best approaches to handling connections, transations, rollbacks etc?

How about CDI support? Looking around online it seems at this time MyBatis only supports two Dependency Injection (JSR-330) frameworks, Google Guice and Spring. I did run into CDI Extensions which may be something look into.

My idea would be to have the container handle all of the above however it may be difficult getting to that point.

Any tips, hints, experiences?

like image 353
Begui Avatar asked Dec 08 '25 12:12

Begui


2 Answers

There is a new mybatis-cdi module. It is not released yet, but you can try the snapshot, it is at github: https://github.com/mybatis/cdi

like image 86
mnesarco Avatar answered Dec 10 '25 10:12

mnesarco


There is no CDI support at all but as you said, if you want DI go Spring or Guice.

With JBoss you have mainly two chances: - EJB 3 - Spring

If using EJB 3 transactions are handled automatically by them. MyBatis just ignores transactions and lets the container commit/rollback.

When using Spring, MyBatis ties to Spring transactions using the integration module MyBatis-Spring.

like image 35
Diego Lopez Avatar answered Dec 10 '25 10:12

Diego Lopez