CAMEL-24615: camel-jpa - Fix the tests failing under the hibernate profile - #26074
CAMEL-24615: camel-jpa - Fix the tests failing under the hibernate profile#26074JiriOndrusek wants to merge 2 commits into
Conversation
The entity uses property access, so the derived isExpired() getter was
treated as a persistent property without a setter and Hibernate failed to
build the SessionFactory ("Could not locate setter method for property
'expired'"). On Quarkus this broke any application with camel-jpa on the
classpath, since the entity is auto-discovered and mapped with Hibernate.
The fix is covered by the new KeyValueEntryHibernateMappingTest, which runs
in every bu.
The OpenJPA enhancer -javaagent is now configured only while the openjpa
profile is active: the agent jar is copied to target/ by that profile alone,
so with -Dhibernate the forked test JVM pointed at a missing jar and failed
to start. The OpenJPA persistence.xml configuresopenjpa provcider
(as hibernate is now on classpath)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 9 tested, 27 compile-only — current: 10 all testedMaveniverse Scalpel detected 36 affected modules (current approach: 10).
|
gnodet
left a comment
There was a problem hiding this comment.
Good work fixing the Hibernate profile compatibility issues. The @Transient annotation on isExpired(), the hbm2ddl.auto change from create to update, and the explicit SELECT column list are all well-motivated. A few items to address:
-
Persistence unit property naming inconsistency — the new
keyvalueDbunit inprofiles/hibernate/META-INF/persistence.xmlusesjakarta.persistence.jdbc.driver/jakarta.persistence.jdbc.urlwhile all 5 other units usehibernate.connection.driver_class/hibernate.connection.url. It also omitshibernate.dialect. Interestingly, the newKeyValueEntryHibernateMappingTestJava class in this same PR uses the Hibernate-native property names. Aligning the XML to match would improve maintainability. -
Stacked PR merge order — This PR includes commit
2557e435from the still-open PR #26068 (CAMEL-24604). If #26068 is merged first, squash-merging this PR will include those changes twice (harmless but confusing in history). If this one is merged first, #26068 becomes redundant. Worth clarifying the intended merge order. -
Commit message quality — The first commit subject has two leading spaces, and the body contains truncations/typos ("in every bu.", "configuresopenjpa provcider"). These will persist in git history — worth cleaning up before merge.
📋 PR Metadata
| Aspect | Current | Suggested |
|---|---|---|
| Labels | components |
+ bug |
| Milestone | (none) | 4.23.0 |
Backport: NOT_NEEDED — KeyValueEntry was introduced in the 4.23 cycle and doesn't exist on any maintenance branch.
This review was generated by an AI agent and may contain inaccuracies. Please verify all suggestions before applying.
Claude Code on behalf of Guillaume Nodet
…ofile With the hibernate profile runnable again (CAMEL-24604), 7 tests failed and fixing them surfaced further OpenJPA-specific assumptions in the test suite: - the "camel" unit used hbm2ddl.auto=create, which drops and recreates the schema whenever an additional JPA endpoint creates its EntityManagerFactory mid-test; "update" is additive like OpenJPA's SynchronizeMappings - AbstractJpaMethodSupport cleaned up via em.joinTransaction() inside a Spring TransactionTemplate, which enlists only under OpenJPA; under Hibernate it silently began a local transaction that was never committed. A plain resource-local transaction is used instead, and the orphaned Address rows are deleted as well since bulk deletes do not cascade - JpaProducerWithQueryTest asserted positional columns of a "select *" native query whose column order depends on the provider-generated DDL; the query now selects explicit columns - the keyvalueDb unit uses the same hibernate.dialect / hibernate.connection.* property style as the other units in the hibernate persistence.xml (review feedback on apache#26074) Both profiles are green: 119 tests with -Dhibernate and 119 by default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
c380f48 to
a12a6b0
Compare
|
Thanks for the review!
|
Fixes CAMEL-24615.
Requires CAMEL-24604 (#26068), which makes the hibernate profile runnable again — this change is stacked on top of it and fixes the 7 tests that then fail, all rooted in OpenJPA-specific assumptions in the test suite:
camelunit usedhbm2ddl.auto=create, which drops the schema whenever anadditional JPA endpoint creates its EntityManagerFactory mid-test;
updateisadditive like OpenJPA's
SynchronizeMappingsAbstractJpaMethodSupportrelied onem.joinTransaction(), which enlists onlyunder OpenJPA — under Hibernate it began a never-committed local transaction, so
cleanup was silently lost; replaced with a plain resource-local transaction (plus
deleting orphaned
Addressrows, as bulk deletes do not cascade)select *, whose column order isprovider-DDL-dependent; it now selects explicit columns
Both profiles green: 119 tests with
-Dhibernate, 119 by default.🤖 Generated with Claude Code
Description
Target
mainbranch)Tracking
Apache Camel coding standards and style
mvn clean install -DskipTestslocally from root folder and I have committed all auto-generated changes.AI-assisted contributions
Co-authored-bytrailers) and the PR description identifies the AI tool used.