On Oct 31, 2006, at 10:15 AM, Kevin Williams wrote:

You may have thought of this already but it would be good to consider how SDO might play with this JPA integration.
I think it would be interesting to have the ability for SDO to handle the "remoting" of JPA entities. For example, a service should be able to retrieve entities using an EntityManager and pass those back to a client. The databinding infrastructure in SCA would transparently transform the entities into a form that the binding used to connect the client to service could serialize out. If the client were an SCA component, the serialization that came back could be transparently converted to POJOs and merged with the JPA entities. What would be nice is if the developer never has to generate classes or deal with factories at all with the exception that entities passed over remote boundaries implement Serializable (required by the JPA spec). Something like

public class OrderServiceImpl implements OrderService {
        @PersistenceContext(unitName = "orderDB")
        protected EntityManager em;

        // transaction semantics defined using SCA policy       
        Order getOrderById(String id) {
                return entityManager.find(Order.class, id);
        }

        // transaction semantics defined using SCA policy       
        void updateOrder(Order order) throws OrderUpdateException{
                return entityManager.merge(order);
        }

}

public class ClientComponent {
        
        @Reference
        protected OrderService orderService;

        public void updateOrder(.....){
                Order order = orderService.getOrderById(orderNum);
                // do something to the order
                orderService.updateOrder(order);
        }

}

The ClientComponent could be wired to OrderService over some remote binding. SDO could be used in the client to only send back the delta during the call to updateOrder(). If the binding were binary, I imagine SDO could even forgo XML and use some optimized representation.

Patrick Linksey from OpenJPA mentioned to me a while back he would be interested in providing an SDO wrapper over OpenJPA. This may be something we want to look into once we get the JPA integration into SCA working.

JIm

--
Kevin


Meeraj Kunnumpurath wrote:

Hi,

I have made a start on JPA integration. Haven't got to do much because
of the build problems. The current home is
sca/services/persistence/common.

Anyway, this is a brief highlight of my thinking ...

1. Support injection of entity manager factory and entity manager
instances using PersistenceUnit and PersistenceContext annotations on
member fields.
2. For entity manager factory instances, the unitName attribute is
introspected at the component load time and scans all the available
persistence.xml for matching unit name.
3. The JPA provider API is used for creating the entity manager factory.
4. Entity manager factory is caches somewhere (System composite)
5. This is then reused in all the components using the same persistence
unit.

Persistence context is trickier. Entity manager AFAIK are thread unsafe
and mostly bound to transactions. Hence, either we will have to proxy
this or use some sort of instance pooling and thread confinement in our component management. I think, proxying would be simpler. I plan to get
at least the EMF side working by end of this week, if I can get the
build going.

Ta
Meeraj


*****************************************************

   You can find us at www.voca.com

*****************************************************
This communication is confidential and intended for the exclusive use of the addressee only. You should not disclose its contents to any other person. If you are not the intended recipient please notify the sender named above immediately.

Registered in England, No 1023742,
Registered Office: Voca Limited
Drake House, Three Rivers Court,
Homestead Road, Rickmansworth,
Hertfordshire, WD3 1FX


This message has been checked for all email viruses by MessageLabs.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to