Jiri Ondrusek created CAMEL-26106:
-------------------------------------

             Summary: camel-jpa: don't hard-wire the Spring based 
DefaultTransactionStrategy as the default transaction strategy
                 Key: CAMEL-26106
                 URL: https://issues.apache.org/jira/browse/CAMEL-26106
             Project: Camel
          Issue Type: Improvement
          Components: camel-jpa
            Reporter: Jiri Ondrusek
            Assignee: Jiri Ondrusek
             Fix For: 4.22.3, 4.24.0


camel-jpa creates the Spring based {{DefaultTransactionStrategy}} 
(spring-orm/spring-tx {{TransactionTemplate}}) with {{new}} whenever no 
{{TransactionStrategy}} is configured (4.23.0):
* {{JpaComponent.createTransactionStrategy()}} (JpaComponent.java:188)
* {{JpaEndpoint.createTransactionStrategy()}} (JpaEndpoint.java:593-594)
* {{JpaMessageIdRepository.createDefaultTransactionStrategy()}}, used by the 
2-arg constructor (JpaMessageIdRepository.java:61, 80-81)
* {{JpaKeyValueRepository.doInit()}} (JpaKeyValueRepository.java:478-479)

Runtimes without Spring can't use these defaults, even when they provide their 
own {{TransactionStrategy}}. Camel Quarkus excludes Spring from camel-jpa, 
removes {{DefaultTransactionStrategy}} and patches all 4 call sites by bytecode 
transformation to use its own {{QuarkusTransactionStrategy}}. Without that, 
GraalVM native builds fail as soon as one of these methods is reachable, e.g. 
when camel-management registers the repositories for reflection 
(apache/camel-quarkus#9385):
{noformat}
Discovered unresolved type during parsing: 
org.apache.camel.component.jpa.DefaultTransactionStrategy
  at JpaMessageIdRepository.<init>(JpaMessageIdRepository.java:61)
{noformat}

*Proposal:* when no strategy is set, first look up a {{TransactionStrategy}} in 
the registry ({{findSingleByType}}), and only then fall back to 
{{DefaultTransactionStrategy}}, created without a hard reference in these 
classes (e.g. one small factory method in a single place, or loaded via 
{{FactoryFinder}}). Runtimes like Camel Quarkus can then register their 
strategy as a bean and drop their bytecode transformations. Existing Spring 
users see no change.

*Backport:* please also to 4.22.x (LTS), so Camel Quarkus releases on that line 
can remove their workaround as well. There {{JpaKeyValueRepository}} doesn't 
exist, so it covers the other 3 call sites.

_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