Skip to content

CAMEL-24615: camel-jpa - Fix the tests failing under the hibernate profile - #26074

Open
JiriOndrusek wants to merge 2 commits into
apache:mainfrom
JiriOndrusek:fix/CAMEL-24615
Open

CAMEL-24615: camel-jpa - Fix the tests failing under the hibernate profile#26074
JiriOndrusek wants to merge 2 commits into
apache:mainfrom
JiriOndrusek:fix/CAMEL-24615

Conversation

@JiriOndrusek

Copy link
Copy Markdown
Contributor

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:

  • the camel unit used hbm2ddl.auto=create, which drops the schema whenever an
    additional JPA endpoint creates its EntityManagerFactory mid-test; update is
    additive like OpenJPA's SynchronizeMappings
  • AbstractJpaMethodSupport relied on em.joinTransaction(), which enlists only
    under 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 Address rows, as bulk deletes do not cascade)
  • a native query asserted positional columns of select *, whose column order is
    provider-DDL-dependent; it now selects explicit columns

Both profiles green: 119 tests with -Dhibernate, 119 by default.

🤖 Generated with Claude Code

Description

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

AI-assisted contributions

  • If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., Co-authored-by trailers) and the PR description identifies the AI tool used.

  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>
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-jpa

🔬 Scalpel shadow comparison — Scalpel: 9 tested, 27 compile-only — current: 10 all tested

Maveniverse Scalpel detected 36 affected modules (current approach: 10).

⚠️ Modules only in Scalpel (26)
  • apache-camel
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

Skip-tests mode would test 9 modules (1 direct + 8 downstream), skip tests for 27 (generated code, meta-modules)

Modules Scalpel would test (9)
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-jpa
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-endpointdsl
  • camel-endpointdsl-support
  • camel-itest
  • camel-jbang-core
  • camel-jbang-it
  • camel-jbang-main
  • camel-jbang-plugin-edit
  • camel-jbang-plugin-generate
  • camel-jbang-plugin-kubernetes
  • camel-jbang-plugin-test
  • camel-kamelet-main
  • camel-launcher
  • camel-report-maven-plugin
  • camel-route-parser
  • camel-yaml-dsl
  • camel-yaml-dsl-deserializers
  • camel-yaml-dsl-maven-plugin
  • coverage
  • docs
  • dummy-component

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (36 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: JPA
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@gnodet gnodet left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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:

  1. Persistence unit property naming inconsistency — the new keyvalueDb unit in profiles/hibernate/META-INF/persistence.xml uses jakarta.persistence.jdbc.driver / jakarta.persistence.jdbc.url while all 5 other units use hibernate.connection.driver_class / hibernate.connection.url. It also omits hibernate.dialect. Interestingly, the new KeyValueEntryHibernateMappingTest Java class in this same PR uses the Hibernate-native property names. Aligning the XML to match would improve maintainability.

  2. Stacked PR merge order — This PR includes commit 2557e435 from 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.

  3. 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>
@JiriOndrusek

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

  1. Merge order: CAMEL-24604: camel-jpa - Mark KeyValueEntry.isExpired() as @Transient #26068 (CAMEL-24604) goes first; this PR will then be rebased onto main — which drops the duplicated 2557e43 from its history — and merged afterwards.

  2. The commit message issues (leading spaces, typos) are in 2557e43, i.e. they belong to CAMEL-24604: camel-jpa - Mark KeyValueEntry.isExpired() as @Transient #26068 — after the rebase that commit will no longer be part of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants