Topic
  • 2 replies
  • Latest Post - ‏2011-11-23T04:49:09Z by KeithPrescott
KeithPrescott
KeithPrescott
11 Posts

Pinned topic JPA in SCA

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

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?

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

    Re: JPA in SCA

    ‏2011-11-21T20:03:58Z  
    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
    http://jaxb.java.net/guide/Mapping_cyclic_references_to_XML.html

    ________________________________________________________________
    "If you prefer to speak in Spanish, please contact me directly"
  • KeithPrescott
    KeithPrescott
    11 Posts

    Re: JPA in SCA

    ‏2011-11-23T04:49:09Z  
    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
    http://jaxb.java.net/guide/Mapping_cyclic_references_to_XML.html

    ________________________________________________________________
    "If you prefer to speak in Spanish, please contact me directly"
    That is helpful, thanks Victor