Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial draft of Jakarta Persistence/CDI EE integration tests #1623

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

starksm64
Copy link
Contributor

@starksm64 starksm64 commented Oct 30, 2024

This is a work in progress. The glassfish version in use does not seem to have a Jakarta Persistence integration that supports the custom qualifiers for injecting an EntityManager.

Fixes Issue
#1405

Related Issue(s)
Specify any related issue(s) links.

Describe the change
A clear and concise description of the change.

Additional context
Add any other context about the problem here.

CC @alwin-joseph @anajosep @arjantijms @cesarhernandezgt @dblevins @m0mus @edbratt @gurunrao @jansupol @jgallimore @kazumura @kwsutter @LanceAndersen @bhatpmk @RohitKumarJain @shighbar @gthoman @brideck @OndroMih @dmatej
@starksm64 @scottmarlow

@starksm64 starksm64 marked this pull request as draft October 30, 2024 05:17
@starksm64
Copy link
Contributor Author

starksm64 commented Oct 30, 2024

Glassfish issue for handling Jakarta Persistence 3.2 changes: eclipse-ee4j/glassfish#25198

@arjantijms arjantijms changed the title Initial draft of JPA/CDI EE integration tests Initial draft of Jakarta Persistence/CDI EE integration tests Nov 7, 2024
Signed-off-by: Scott M Stark <[email protected]>
@@ -332,6 +332,17 @@
<artifactId>derbytools</artifactId>
<version>10.15.2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.main.deployment</groupId>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just temp to help with debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, leftover from looking at adding a glassfish annotation handler to the test deployment.

@arjantijms
Copy link
Contributor

@starksm64 some things I don't understand yet about this commit.

<persistence-unit name="CTS-EM" transaction-type="JTA">
    <description>Persistence Unit for CTS Vehicle Tests</description>
    <qualifier>ee.jakarta.tck.persistence.ee.cdi.CtsEmQualifier</qualifier>
    <jta-data-source>jdbc/DB1</jta-data-source>
    <class>ee.jakarta.tck.persistence.ee.entityManager.Order</class>
  </persistence-unit>

  <persistence-unit name="CTS-EM2" transaction-type="JTA">
    <description>Persistence Unit for CTS Vehicle Tests</description>
    <qualifier>ee.jakarta.tck.persistence.ee.cdi.CtsEmQualifier</qualifier>
    <jta-data-source>jdbc/DB1</jta-data-source>
    <class>ee.jakarta.tck.persistence.ee.entityManager.Order</class>
  </persistence-unit>

Both persistence units have the same qualifier. That doesn't seem to be allowed, as it will lead to ambigious candidates for injection.

Additionally, the spec uses cdi:scope here and cd:qualifier, but your example doesn't use that namespace:

https://github.com/jakartaee/platform/blob/main/specification/src/main/asciidoc/webprofile/jpa-cdi/CDI-JPA.adoc

@hantsy
Copy link

hantsy commented Nov 23, 2024

If Glassfish handled the persistence and CDI integration when switching to another persistence provider that provides the CDI integration, it will cause a conflict?

@arjantijms
Copy link
Contributor

If Glassfish handled the persistence and CDI integration when switching to another persistence provider that provides the CDI integration, it will cause a conflict?

Basically, if that persistence provider included a CDI extension in its main jar / maven dependency. Although I don't think Hibernate will do this.

I think it's architecturally wrong for GlassFish to provide this. We also don't let GlassFish handle all the CDI concerns for Mojarra, Cocurro, or Soteria, just to name three.

But for EE 11 the ship has sailed, and we have to do it like this.

@scottmarlow
Copy link
Contributor

<persistence-unit name="CTS-EM" transaction-type="JTA">
    <description>Persistence Unit for CTS Vehicle Tests</description>
    <qualifier>ee.jakarta.tck.persistence.ee.cdi.CtsEmQualifier</qualifier>
    <jta-data-source>jdbc/DB1</jta-data-source>
    <class>ee.jakarta.tck.persistence.ee.entityManager.Order</class>
  </persistence-unit>

  <persistence-unit name="CTS-EM2" transaction-type="JTA">
    <description>Persistence Unit for CTS Vehicle Tests</description>
    <qualifier>ee.jakarta.tck.persistence.ee.cdi.CtsEmQualifier</qualifier>
    <jta-data-source>jdbc/DB1</jta-data-source>
    <class>ee.jakarta.tck.persistence.ee.entityManager.Order</class>
  </persistence-unit>

Both persistence units have the same qualifier. That doesn't seem to be allowed, as it will lead to ambigious candidates for injection.

^ appears to be resolved now as the qualifier for CTS-EM2 was updated.

@arjantijms
Copy link
Contributor

^ appears to be resolved now as the qualifier for CTS-EM2 was updated.

Indeed, I updated it myself. Unfortunately I never heard back from @starksm64 about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants