Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » JPA, separate bundles for model and services(How to configure JPA for separate model and service )
JPA, separate bundles for model and services [message #962986] Mon, 29 October 2012 13:35 Go to next message
Erik Vande Velde is currently offline Erik Vande Velde
Messages: 62
Registered: September 2012
Member
I separated out the model of my application and the services that use this model. Now I'm not sure how I should configure JPA in the OSGi world. Do I put the persistence.xml in the model module or in the service? I opted to put it in the service, but then it complains that it didn't find any entities, while many classes in the model module carry the '@Entity' annotation.
Re: JPA, separate bundles for model and services [message #963041 is a reply to message #962986] Mon, 29 October 2012 14:25 Go to previous messageGo to next message
Tin N/A is currently offline Tin N/A
Messages: 46
Registered: December 2010
Member
persistence.xml is used when EntityManager is created, so you need to put it in the bundle where you're constructing your EntityManager and accessing it.
The reason it might complain that it can't find annotated classes could be caused if you're not importing them. Remember that annotations are an "optional extra" so your annotated classes will still be accepted by JVM event though annotation definitions themselves can't be found. So, make sure you're also importing all the annotation packages into the bundle where your EntityManager is instanced.
Re: JPA, separate bundles for model and services [message #964025 is a reply to message #963041] Tue, 30 October 2012 07:46 Go to previous messageGo to next message
Erik Vande Velde is currently offline Erik Vande Velde
Messages: 62
Registered: September 2012
Member
This entity annotation is coming from the bundle com.springsource.javax.persistence, and I imported that bundle, version [2.0.0,2.0.0], in both modules (model and service). So I guess that's not the reason why the service doesn't recognize the model class as an entity.
Re: JPA, separate bundles for model and services [message #964393 is a reply to message #962986] Tue, 30 October 2012 13:29 Go to previous message
Erik Vande Velde is currently offline Erik Vande Velde
Messages: 62
Registered: September 2012
Member
I got it working by enumerating all my domain classes in the persistence.xml of the service. It would be much nicer if JPA could find the annotated classes automatically, but apparently it only searches within the main project, so the service in my case. http://static.springsource.org/spring-data/data-jpa/docs/current/reference/html/#jpa.misc.entity-scanning says that spring 3.1 would offer a solution for this, but current Virgo (3.5) still works with spring 3.0.5, where this solution doesn't work yet ...
Previous Topic:dynamic jasper osgi bundle
Next Topic:Is Virgo used in production environments?
Goto Forum:
  


Current Time: Fri Oct 24 13:01:17 GMT 2014

Powered by FUDForum. Page generated in 0.01747 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software