我以前曾试图做过类似的事情,或许只是就我的调查结果谈一旁(当时我正在利用Hibernate + XFire为WS)。
我认为,你们的思想在理论上是行之有效的。 你们需要做的是,简单地将管理的实体编成册,并将其发送给客户。 客户(当然,客户终端,完全是正常的POJO,而不是管理的实体),将其送回服务器。 此时此刻,被服务器击落的物体只是一个过时的物体。 你可以回头来开会(JPA/Hibernate将为你们做这些乐观的一致检查),并坚持不懈。
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.