Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have tried to do similar things before and maybe just share a bit on my findings (I was using Hibernate + XFire for WS that time)</p> <p>I believe what you are thinking works theoretically. What you need to do is simply serialize your managed entities and send it to client. Client deserialize and update the object (of course, on client's end, it is simply normal POJO, not managed entities) and send it back to server. At this point, the object recieved by Server is simply a detached object. You can reattach to session (JPA/Hibernate will do those optimistic concurrency check for you), and do your persistence.</p> <p>However it only works fine for very simply POJO. One of the major problem is, in JPA (or mostly all ORM framework) you are having relationships between different entities. For example, an Order will have relationships to Product and Account, an Account will have relatinships to Client, Client will have list of Addresses.... etc. It is mostly fine if you are manipulating in server side because of lazy fetching, relationships are not actually fetched until you access it. However when you perform serialization, it become a difficult problem to solve: most serialization solution like JAXB will simply navigate all properties recursively. The result is, you expect to send only the Order object to client side, but finally you are sending a huge piece of data to Client. Simply telling the serializer not to serialize some properties is not going to work, coz when the object is sent back and reattach the detached obj to session, JPA/Hibernate have no way to know that if you are simply ignoring the relationship or you are actually removing the relationship. Of course there are still some tricks you can do but all these makes such approach painful to adopt and it is no longer elegant.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload