| // Do not edit directly! |
| // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page |
| [id="extensions-jpa"] |
| = JPA |
| :page-aliases: extensions/jpa.adoc |
| :linkattrs: |
| :cq-artifact-id: camel-quarkus-jpa |
| :cq-native-supported: true |
| :cq-status: Stable |
| :cq-status-deprecation: Stable |
| :cq-description: Store and retrieve Java objects from databases using Java Persistence API (JPA). |
| :cq-deprecated: false |
| :cq-jvm-since: 1.0.0 |
| :cq-native-since: 1.0.0 |
| |
| ifeval::[{doc-show-badges} == true] |
| [.badges] |
| [.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0## |
| endif::[] |
| |
| Store and retrieve Java objects from databases using Java Persistence API (JPA). |
| |
| [id="extensions-jpa-whats-inside"] |
| == What's inside |
| |
| * xref:{cq-camel-components}::jpa-component.adoc[JPA component], URI syntax: `jpa:entityType` |
| |
| Please refer to the above link for usage and configuration details. |
| |
| [id="extensions-jpa-maven-coordinates"] |
| == Maven coordinates |
| |
| https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-jpa[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"] |
| |
| Or add the coordinates to your existing project: |
| |
| [source,xml] |
| ---- |
| <dependency> |
| <groupId>org.apache.camel.quarkus</groupId> |
| <artifactId>camel-quarkus-jpa</artifactId> |
| </dependency> |
| ---- |
| ifeval::[{doc-show-user-guide-link} == true] |
| Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. |
| endif::[] |
| |
| [id="extensions-jpa-additional-camel-quarkus-configuration"] |
| == Additional Camel Quarkus configuration |
| |
| The extension leverages https://quarkus.io/guides/hibernate-orm[Quarkus Hibernate ORM] to provide the JPA implementation via Hibernate. |
| |
| Refer to the https://quarkus.io/guides/hibernate-orm[Quarkus Hibernate ORM] documentation to see how to configure Hibernate and your datasource. |
| |
| Also, it leverages https://quarkus.io/guides/transaction#programmatic-approach[Quarkus TX API] to provide `TransactionStrategy` implementation. |
| |
| When a single persistence unit is used, the Camel Quarkus JPA extension will automatically configure the JPA component with a |
| `EntityManagerFactory` and `TransactionStrategy`. |
| |
| [id="extensions-jpa-configuration-configuring-jpamessageidrepository"] |
| === Configuring JpaMessageIdRepository |
| It needs to use `EntityManagerFactory` and `TransactionStrategy` from the CDI container to configure the `JpaMessageIdRepository`: |
| [source, java] |
| ---- |
| @Inject |
| EntityManagerFactory entityManagerFactory; |
| |
| @Inject |
| TransactionStrategy transactionStrategy; |
| |
| from("direct:idempotent") |
| .idempotentConsumer( |
| header("messageId"), |
| new JpaMessageIdRepository(entityManagerFactory, transactionStrategy, "idempotentProcessor")); |
| ---- |
| |
| [NOTE] |
| ==== |
| Since it excludes the `spring-orm` dependency, some options such as `sharedEntityManager`, `transactionManager` are not supported. |
| ==== |
| |