[
https://issues.apache.org/jira/browse/OPENJPA-3101?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18152403#comment-18152403
]
Richard Zowalla commented on OPENJPA-3101:
------------------------------------------
One point for the implementation: please take the BeanManager from the property
jakarta.persistence.bean.manager first, and only fall back to the JNDI lookup
or CDI.current\(\) if it is not set.
The spec defines where the BeanManager comes from: sections 3.6.1 \(entity
listeners\) and 3.9 \(attribute converters\) both start with "Obtain a
BeanManager instance. \(See Section 9.1\)", and 9.1 says: "The container is
responsible for passing this BeanManager instance via the map that is passed as
an argument to the createContainerEntityManagerFactory call. The map key used
must be the standard property name jakarta.persistence.bean.manager."
TomEE already passes it \(EntityManagerFactoryCallable\), as a lazy proxy,
because the EMF is often created before CDI is started for the application. The
setup from OPENJPA\-3089, which this issue reuses, does not read the property
yet, so it would be good to add it there.
> Add context interception to AttributeConverter when running in CDI environment
> ------------------------------------------------------------------------------
>
> Key: OPENJPA-3101
> URL: https://issues.apache.org/jira/browse/OPENJPA-3101
> Project: OpenJPA
> Issue Type: Improvement
> Reporter: Paulo Cristovão de Araújo Silva Filho
> Assignee: Paulo Cristovão de Araújo Silva Filho
> Priority: Major
>
> According to Jakarta Persistence API 3.2 item
> [3.9|https://jakarta.ee/specifications/persistence/3.2/jakarta-persistence-spec-3.2.html#a2999],
> the persistence provider should:
> a) in Jakarta EE environments:
> a.1) use CDI SPI to create instances of the attribute converter class;
> a.2) perform injection upon such instances;
> a.3) invoke their {{PostConstruct}} and {{PreDestroy}} methods, if any; and
> a.4) dispose of the attribute converter instances; and
> b) in environments where CDI is not enabled, must not invoke attribute
> converters that depend upon CDI injection.
> The current behavior of OpenJPA is to call the attribute converters
> regardless they have injected annotated fields, although without the actual
> injection, which leads to NPEs.
> Proposed impl with further the work made on OPENJPA-3089, adopting similar
> architecture and the default non-cdi previous behaviour.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)