I'm trying to get a system working whereby different bundles are able to
register different entities.
The first thing I researched was whether there's a way to add new
persistable entities to an entity manager at runtime. If that can be
done then, problem solved. But I can't find a way to do that.
The second thing I tried was to have an entity manager per registering
bundle, and unify all the entity managers under a central persistence
manager which would then determine which entity manager was appropriate
for a given call. I tried this by way of having each bundle have a
derived persistence service which proxies the usual calls (eg clear(),
contains(Object), etc) but also has a list of class types so that it
knows what it manages. Then, the manager calls a method
contains(Class<?>) to find the right manager and proxies to it. This is
fine for stuff like clear() (clear all managers), and contains(Object)
(find the right one), but things snag for calls like createQuery() which
potentially involve objects across managers, such that there IS no
appropriate manager to proxy to.
I read through the aries JPAEntityManager in hopes it would have some
goodies for scenarios like this, but was unable to find anything.
The openjpa documentation explicitly says that entities CAN be added
after startup, but I've been unable to find how one would do such a
thing. I'm doing enhancement at build-time so, that part isn't a
problem, I just need something like public void
manager.addEntity(class<?>) or public void
manager.entityManagerUnion(EntityManager mergeWithMe).
Am I missing something simple here?
-Jamie