I'm architecting a some what exceptional situation. In this setup the client has a "universal business model", but each of the entities may be managed by a different application, storing its data in separate databases. The business model is overlapping all applications, but part of it may be "local" and part of it may be remote.
There are many approaches to this setup; for example one could use a big event bus and synchronize many readonly copies with one writable at database level. Another approach, which I'm currently investigating, is that the BM model knows where to get things.
In this scenario there are DAO objects with persist, remove and findBy* methods, which know whether to load from a database or retrieve through REST (for example). The challenge will be to hook into relationship methods. Suppuse I have a user and want to get its groups, I would do this by calling getGroups() and the JPA annotations will result in a fetch to the database. But what if those groups are stored elsewhere and I need to issue a REST GET to get them?
Does Eclipselink go through the entity manager in order to lazy load dependencies? So we can hook into one of its methods? Or does it directly get a connection and runs the SQL?
You can use a QueryRedirector on any mapping to provide your own code for the query. But the relationship is not persistent, you should probably just not map it, and use your get method to perform the access.
JPA and EclipseLink also have PostLoad/PostBuild events that allow you to perform you own code.
EclipseLink also has NoSQL support, and composite persistent units. So you can have relationships that are stored in different databases.