Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipselink-users] Service/DAO/Model Bundles

The restriction right now as I know it is this:

The EntityManager and the EO's must share the same classloader (i.e.
be in the same bundle).

I think you're going to be stuck passing in your Entity Manager in to
your "DAO" layer.

Here's the model we use for our OSGi J2SE RCP apps.

 - Model Bundle: Contains the Entity Manager, EO's and "model
classes", which would act like your dao, they hold a copy of an
EntityManager and any special data access calls.
 - View Bundle: Contains all the GUI/Front end code, no data access.
 - Utility Bundles: Contain things like abstract classes (Mapped Super
Classes), Abstract Entity Manager Factories, etc.

This has worked out fine, but some things that aren't great is, if you
have 4 different model bundles that all need to access a common
database table like a Users table each bundle must duplicate code and
have the same EO. It's not a huge deal since EO's stay pretty light,
but it's not ideal obviously.

If you'd like some more details let me know.


On Mon, Jun 23, 2008 at 3:56 AM, Bellan Saravanan <sarbx@xxxxxxxxxxx> wrote:
> Hello,
> I need some advice on the organization of bundles for my database
> application in OSGi.
> This is what I was thinking,
> 1) Model Bundle
> This will contain all the Entity objects with annotations also the
> persistence.xml file and the JPA-PersistenceUnits manifest headers.
> 2) DAO Bundle
> This will contain the DAO classes containing all the get/set/delete methods,
> but without any transaction semantics.
> 3) Service Bundle
> This will contain all the domain logic and will invoke the DAO classes as
> appropriate. This method should start and end the transaction. (preferably
> with some annotation approach)
> The problem I'm having is with the sharing of EntityManager instance across
> the DAO and the Service bundle, since I want the Service to handle all
> transactional aspects.
> The questions I have are,
> a) Is there anyway for the DAO bundle to use the Entitymanager created by
> the Service bundle, without actually passing the EntityManager as a
> parameter.
> b) Also I read that DI annotations like @PersistenceContext does not work in
> the OSGi container. Is this still true?
> c) I would also prefer to use Spring JPA/Spring DM. Has anyone used the
> Spring OSGi support for wokring with EclipseLink in a similar configuration.
> Thanks,
> ________________________________
> Earn cashback on your purchases with Live Search - the search that pays you
> back! Learn More
> _______________________________________________
> eclipselink-users mailing list
> eclipselink-users@xxxxxxxxxxx


Back to the top