Design Specification: Remote JPA
|Date||Author||Version Description & Notes|
Remote JPA would allow access to the JPA API from a remote Java client. This would allow fat Java clients to access the richness of the JPA API, and not require a data transfer layer. This can avoid the need for remote SessionBeans, merging, and data transfer objects. It provides querying, transactions, change tracking, and lazy relationship support on the Java client.
It could also be used in distributed architectures to perform database intensive work closer to the database, for more optimal interaction.
- Java fat-client - client user interface is Java, (versus html), this could be a Java desktop or WebStart application, Java applet, or possibly an Android client.
- RMI - Java communication framework, makes use of Java serialization to send objects.
- CORBA - language independent communication framework
- RemoteSession - existing EclipseLink feature that provides the EclipseLink native Session API to a remote Java client.
- JPA API
- query execution
- transaction/unit of work
- change tracking, flushing
- lazy relationships
- load groups, eager relationships
- security - need to determine how security will be provided
- communication protocol - what protocols should be supported
- serialization - should provide alternative serialization options to Java serialization
Currently EclipseLink supports a RemoteSession feature which allows remote access through the Session API.
The following is required to enable this functionality through JPA:
- JPA classes must accept any Session type (AbstractSession instead of DatabaseSession).
- JPA uses attribute change tracking, which does not work with current RemoteSession.
- JPA supports flush (RepeatableWriteUnitOfWork), which does not work with current RemoteSession.
- JPA requires more meta-data than RemoteSession currently exposes through descriptor serialization.
The JPA API will be the same on client versus server. Remote connection properties will be specified through persistence unit properties.
RemoteSession supports sending DatabaseQuery objects, as well as calling queries remotely by name.
Currently JPA parses JPQL to create a DatabaseQuery, so this will need to occur on the client, or a new type of generic JPQL DatabaseQuery will need to be used. Named queries in JPA are not currently invoked as named queries in the Session, but just looked-up and executed normally. A different mechanism would be required to execute a query remotely by name.
The queries could be prepared on the client or on the server. Preparing on the client could mean more data is serialized as part of the query definition, but it could also mean less data as SQL is less data than serialized Criteria or Expression objects. Preparing the queries on the client is the simpler solution, so will be used in the first phase. Preparing queries on the server will be investigated for future phases.
The work will be broken into the following phases:
- JPA will be made compatible with RemoteSession (or any AbstractSession).
- JPA artifacts and meta-data will be ensured to be serializable.
- Basic querying (queries will be prepared on client, database call sent to server)
- Basic units of work (no change tracking, no flushing).
- Complex units of work (change tracking, flushing, etc.)
- Optimized querying (named queries, jpql prepared on server)
- Optimized units of work (only send change sets, no objects)
Will use JPA fieldaccess EntityManager test suite (JPA SRG).
Should be documented under a new Remote JPA section.
|Issue #||Owner||Description / Notes|
|1||Can unit of work commit only send changes, instead of objects?||Currently sends both, commit currently requires objects.|
|2||What communication protocols should be supported?||Currently RMI, maybe CORBA.|
|Issue||Description / Notes||Decision|