Jiří Ondrušek created CAMEL-27239:
-------------------------------------

             Summary: camel-jpa: JpaConsumer.lockSkipLocked calls 
EntityManager.createQuery(CriteriaQuery), which does not exist in Jakarta 
Persistence 4.0
                 Key: CAMEL-27239
                 URL: https://issues.apache.org/jira/browse/CAMEL-27239
             Project: Camel
          Issue Type: Bug
          Components: camel-jpa
            Reporter: Jiří Ondrušek
            Assignee: Jiří Ondrušek


h3. Problem
CAMEL-27057 ("skipLockedEntity skips a locked entity with SKIP LOCKED on 
Hibernate") added {{JpaConsumer.lockSkipLocked}}. At line 483 it calls 
{{EntityManager.createQuery(CriteriaQuery)}}. Camel is compiled against Jakarta 
Persistence 3.2, so the bytecode references that method. Jakarta Persistence 
4.0 (4.0.0-M7, shipped by Quarkus 4.0.0.CR1) does not have it.

h3. What fails in Camel Quarkus
The native image build of the {{jpa}} integration test fails on Camel main with 
Quarkus 4.0.0.CR1 (Camel Quarkus CI run 44485007925, "Native Tests - group-04"):
{noformat}
Fatal error: com.oracle.graal.pointsto.util.AnalysisError$ParsingError: Error 
encountered while parsing 
org.apache.camel.component.jpa.JpaConsumer.lockSkipLocked(JpaConsumer.java:483)
Caused by: com.oracle.graal.pointsto.constraints.UnresolvedElementException: 
Discovered unresolved method during parsing: 
jakarta.persistence.EntityManager.createQuery(jakarta.persistence.criteria.CriteriaQuery).
 This error is reported at image build time because class 
org.apache.camel.component.jpa.JpaConsumer is registered for linking at image 
build time by command line and command line.
{noformat}
Result: BUILD FAILURE in camel-quarkus-integration-test-jpa 
(io.quarkus:quarkus-maven-plugin:4.0.0.CR1:build).

h3. Suggested fix
Make the call resolve to a method that exists in both versions (checked with 
javap in 3.2 and 4.0):
{code:java}
entityManager.createQuery((CriteriaSelect<T>) query)
{code}

h3. Notes
A workaround in Camel Quarkus would need a GraalVM substitution of the class 
(class rewriting), so a fix in Camel is preferred.

_Generated with [Claude Code|https://claude.com/claude-code] on behalf of 
[~jondruse]_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to