Skip to content

Support for JPA 4.0 EntityAgent #36025

@jhoeller

Description

@jhoeller

Following up on basic JPA 4.0 runtime compatibility in #35705, we can add transactional support for EntityAgent management, similar to the existing support for Hibernate's StatelessSession in #7184.

The SmartFactoryBean#getObject(Class) mechanism can be used for dependency injection, along the lines of LocalSessionFactoryBean but following @PersistenceContext-style semantics for the EntityAgent proxy: delegating to a transactional EntityAgent if a transaction is active, performing a non-transactional operation otherwise.

The following additions are to be expected:

  • SharedEntityAgentCreator next to SharedEntityManagerCreator (possibly sharing a common InvocationHandler implementation, in particular a common DeferredQueryInvocationHandler). While this will require building against the JPA 4.0 API, that class is standalone and does not break JPA 3.2 compatibility.
  • AbstractEntityManagerFactoryBean#getObject(Class) supporting a shared EntityAgent instance next to its shared EntityManager. This will require reflective loading of the EntityAgent type without a hard reference to it, plus conditional initialization of an untyped sharedEntityAgent field via SharedEntityAgentCreator that can then be returned from getObject(Class) if the requested type is assignable to the reflectively loaded EntityAgent Class.

Metadata

Metadata

Assignees

Labels

in: dataIssues in data modules (jdbc, orm, oxm, tx)type: enhancementA general enhancement

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions