0

I am using Mybatis 3.3.0 and EJB 3.1 running in a Wildfly 8.2.1 App server.

I modified my EJB's to have a Remote Interface and Injected the interface into all my classes that require the functionality instead of the injecting the LocalBean implementation (as it was before).

This caused all my useGeneratedKeys configurations for my mapper file Insert statements to stop working. Now my ID fields remain Null after the Inserts have run successfullly.

How is it that this caused mybatis to not be able to populate the ID's into my POJOs.

1 Answers1

0

It turns out that mybatis gets confused when your EJB's are proxied and it isn't able to put the generated ID back into the POJO.

To fix it you simply have to inject the EJB Annotated with @javax.ejb.LocalBeanimplementation directly into the class you want to use it in. This is instead of injecting the Interface annotated with @javax.ejb.Remote.

Additionally I tested the same implementation using Remote EJB's and found you still won't be able to get generated Keys back from mybatis if you inject the @javax.ejb.Remote Interface type. I haven't found a solution to getting the generated ID into the POJO when using remoting.