Hi bundletracker gurus!

I'm trying to bridge the latest and greatest Aries-JPA 2 with
spring-data-jpa (could be deltaspike data if simpler).

The problem is that the spring-data repositoryImpl constructor is taking an
entitymanager in argument and that the aries-jpa @PersistenceUnit
annotation does not support constructor injection.

I tried something with Pax-Cdi like this:

[code]
public class Bootstraptor {
@PersistenceUnit(name="myPU")
private EntityManager em;

@Produces
@ApplicationScoped
public EntityManager createEM() {
return em;}
}

public interface MyRepo extends

extends PagingAndSortingRepository<MyEntity, Long>{}

public class MyRepoImpl extends
SimpleJpaRepository<MyEntity, Long> implements MyRepo {

@Inject

public MyRepoImpl (EntityManager em) {

super(MyEntity.class, em);

}

@Eager

public class ServiceExporter {

@Inject

private MyRepo repo;

@Produces

@ApplicationScoped

@OsgiServiceProvider

public MyRepo createRepo() {

return repo;}
}

[/code]

​But, ​it does not seems to work (I just worked 1 or two hours on it, I'll
continue to search), and looks to be a design overkill (if pu injection
would handle constructor injection, I just had to annotate MyRepoImpl with
service annotations and get rid of the bootstraptor and serviceexporter
classes).



Should I raise a Jira on it?

Best regards,

Charlie,

​PS: Also I'm not sure, but it could be nice to have a CDI support for Pu
injection (I'll take a look at it).​


-- 
Charlie Mordant

Full OSGI/EE stack made with Karaf:
https://github.com/OsgiliathEnterprise/net.osgiliath.parent

Reply via email to