Skip to content

Repository to (optionally) return managed JPA entities (JPA integration) #264

@lprimak

Description

@lprimak

Description

As far as I understand it, the repository finder methods return POJOs and not managed entities. In order to integrate with existing JPA codebases, it would be very useful if managed entities were returned.

As a:

  • Application user/user of the configuration itself
  • API user (application developer)
  • SPI user (container or runtime developer)
  • Specification implementer

All that would be needed is a reference to EntityManager. I propose to infer EntityManager from CDI,
similar to what's implemented here: https://docs.flowlogix.com/#section-daohelper

@Inject
// Inject default EntityManager
@EntityManagerSelector
MyRepository<Entity, Key> repository;
@Inject
@EntityManagerSelector(NonDefaultEM.class)
MyRepository<Entity, Key> repository;

where NonDefaultEM is a custom @Qualifier annotation that points to a producer method that injects the appropriate EM.
Default would be no-qualifier injection, which would work in most cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions