MyBatis integration with JBoss 7.1 web application - jboss

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?

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

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.

I would create my own CDI bean - use #Produces for a factory, and #Inject to get the session.
Here is old iBatis Spring factory, that might be the producer, after some changes:
SqlMapClientFactoryBean

Related

Wildfly compatibility with EJB

I’m working on a migration project that woul change WebLogic application server soon to be off support to Wildfly 10.0.0.Final, the problem I’m facing is that the project was built with ejb 2.1 and I don’t know wether Wildfly 10.0.0 would be compatible or not ?
Thanks in advance
Your migration will be relatively easy unless your application makes use of CMP entity beans.
If you have more than around 3 or 4 of these then migration will get tricky as you would need to migrate the CMP beans to JPA.
Otherwise, most changes will revolve around moving to Java EE standard JNDI names

Does Jboss 7.1 AS supports ejb 2.1?

it seems jboss AS 7.1 supports ejb 2.1.Our ejb 2.1 based application is deployed on jboss 5 AS. We are migrating it to jboss7.1. but i want to know what are the additional configurations required to run ejb 2.1 without any errors?
EJB2 is still supported in AS7.x, the issue might be that AS7 is a new implementation and some of the tuning options and configuations are not available for AS7 - especially the EntityBean CMP.
There are some added for EAP6 (based on AS7) you might download the unsupported version.
Wildfly (the successor of JBossAS) will not continue to support EJB2 EntityBeans because EJB3.2 declare it as optional.
Note EJB2 session beans are still supported but I recommend to upgrade it to EJB3 this should faily simple.
You might keep the EJB2 interfaces to provide an interface for EJB2 clients, but I expect effort for the client as well as the lookup Strings changed.
If the appliation should be kept for the future I would recommend to migrate to EJB3

Using Jpa inside apache felix framework implementation

I was trying to implement an OSGi application , application has servlet(implemented using jetty), jaxb(using eclipselink moxy), and Jpa part(the problem part). I was trying to use eclipselink inside apache felix container for jpa functionality, I tried various approach but couldn't implement it. I just need some working example or tutorial link.
The easiest way to use jpa in felix is to use Apache Karaf as it has pre packaged features for eclipselink as well as Aries JPA which makes it easier to use any jpa provider in OSGi.
See example with declarative services, or with blueprint.
For plain felix I recommend to use bndtools to get the list of bundles and also to be able to directly run felix.
I started a tutorial to package and run the tasklist-ds example using bndtools

JPA newbie - Container managed persistence using Websphere and OpenJPA

I want to implement Container Managed persistence using Websphere and OpenJPA.
Can anyone provide some insights ?
Is there a way to achieve this without using EJB3 or Spring ?
EJBs and Spring (along with some other Dependency Injection frameworks like Google Guice) implement the Container Managed EntityManager. If you don't want to use the technology that provides the hooks for the container to handle the transactions and entity managers for you, then you would have to roll your own which is the application managed route.

Migrate from EJB 2 Entity Bean to EJB3

I am having some entity beans created in EJB 2.0 and now I need to migrate to EJB 3.x, but I've studied that use of entity beans are changed in EJB 3.x and they are using JPA instead.
Where can I find solution to actuate my beans to be comfortable with EJB 3.x?
For example from following resources available online:
http://www.datadisk.co.uk/html_docs/ejb/ejb3_migration.htm
http://www.oracle.com/technetwork/middleware/ias/oc4j-twp-ejb3-migration-1013-133021.pdf
or following printed books:
Pro JPA 2 Mastering the Java Persistence API (p. 457-466)
EJB3 in Action (p. 513-528)
IntelliJ EJB refactoring tools might prove to be useful: http://www.jetbrains.com/idea/webhelp/migrating-to-ejb-3-0.html
I belive there are some for Eclipse too.
just for future reference, I recommend the following link:
http://what-when-how.com/enterprise-javabeans-3/migrating-cmp-2-entity-beans-to-the-ejb-3-jpa-part-1/
And there's also part 2 on the same site as well as migrating session beans and MDBs.
I used them and found them very helpful and useful.