I'm not much familiar with JPA, but I have this scenario: I would like to use the same classes (read "code") on both the server and the client (Java SE) for KISS/DRY reasons. It seems to me that one possible way to do this would be to have a (special?) EntityManager
on the client that passes requests for entities to the server and at the end passes all entities back to the server for a "batch persist action" where classes can (re-)validate their data, apply some transactional operations (updating and stuff) and be all persisted nicely by the JPA implementation.
The question is: Is that possible? How? (is there already a solution for this? is it simple, of sorts, to solve this with "some" code?)
Edit: Ok, let me clarify a couple of things for everyone. My background is with an in-house grown application framework that uses what could be called generic persistence services; i.e. services for performing CRUD actions (one service per action for any table) within a single transaction but are backed by classes (within the service) that intercept these actions and offer validation and (often) complicated business rules (with updates to other tables, etc.). That was implemented with older Microsoft products. Now there is a shift to .NET where there have recently appeared similarly-working but more advanced frameworks like DevForce and CSLA. DevForce in particular offers what I'd like to also do in Java (see the "Executing on the client" paragraphs on this page and then visit this page for a better overview).
An older question of mine on this general subject: Java "equivalent" to CSLA