IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2011-11-23T04:49:09Z by KeithPrescott
11 Posts

Pinned topic JPA in SCA

‏2011-11-21T19:13:42Z |

This question is related to my previous post. I would like to use JPA for persistence within a component and SCA to assemble my application that includes services and UI. Using RAD 8 and WebSphere 8, what are the best ways of providing web services that use persistence?

  • OSGi implementation
  • EJB
  • anything else, JPA directly in SCA projects?

Updated on 2011-11-23T04:49:09Z at 2011-11-23T04:49:09Z by KeithPrescott
  • SystemAdmin
    126 Posts

    Re: JPA in SCA

    ‏2011-11-21T20:03:58Z  in response to KeithPrescott
    Hi Keith.

    It depends on which your overall approach is. The one thing I can assure you is that if you want to use JPA persistence managed by the container, then using JPA directly in SCA is not good for you, since the JPA container will not know anything about your JPA project.

    Given said that, now you have two options: Using JPA in an OSGi bundle and use it in an OSGi Application. You will gain all the good benefits of OSGi technology (versioning, modularization, etc...) and the JPA managed persistence feature.

    On the other hand, you also have the possibility to use EJB, although it will tie your solution to an EAR, but if you already have this approach done in your app, then it is fine.

    In my humble opinion I'd say that using JPA in an OSGi app that implements a SCA component is the way to go. One thing you will need to take care (if using JAXB as data type) is that you will need to handle the cyclic references in the JPA entities during marshalling and unmarshalling. Look at the @XmlTransient annotation in the JAXB specification

    "If you prefer to speak in Spanish, please contact me directly"