You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. To skip the boilerplate definition of CRUD operations,
1799
+
<1> To skip the boilerplate definition of CRUD operations,
1800
1800
we can use one of the available interfaces (e.g. `CrudRepository` or `BasicRepository`).
1801
-
2. Adding custom queries with parameters is as easy as providing your query string to the `@Query` annotation.
1802
-
3. If the basic CRUD operations from the Jakarta Data interfaces are not enough,
1801
+
<2> Adding custom queries with parameters is as easy as providing your query string to the `@Query` annotation.
1802
+
<3> If the basic CRUD operations from the Jakarta Data interfaces are not enough,
1803
1803
we can always add a custom one, in this case a delete operation that removes `MyEntity`s by name.
1804
1804
1805
1805
And then the repository can be used as any other bean:
@@ -1817,10 +1817,28 @@ public class MyEntityResource {
1817
1817
repository.insert(entity);
1818
1818
}
1819
1819
1820
-
// ...
1820
+
// ...
1821
+
1822
+
}
1823
+
----
1824
+
1825
+
[NOTE]
1826
+
====
1827
+
When working with non-default persistence units, remember to specify the persistence unit name the repository is targeting
1828
+
in the `dataStore` attribute of the repository annotation:
1821
1829
1830
+
[source,java]
1831
+
----
1832
+
@Repository(dataStore = "other") // <1>
1833
+
public interface MyNonDefaultPURepository {
1834
+
// ...
1822
1835
}
1823
1836
----
1837
+
<1> Pass the name of the non-default persistence unit to the repository annotation (`other` in this example).
1838
+
1839
+
Review the https://jakarta.ee/specifications/data/1.0/apidocs/jakarta.data/jakarta/data/repository/repository#dataStore()[Javadoc of the `@Repository` annotation]
1840
+
to learn more about the `dataStore` attribute.
1841
+
====
1824
1842
1825
1843
Please refer to the corresponding https://hibernate.org/repositories/[Hibernate Data Repositories]
1826
1844
and https://jakarta.ee/specifications/data/1.0/jakarta-data-1.0[Jakarta Data]
Copy file name to clipboardExpand all lines: integration-tests/hibernate-orm-data/src/main/java/io/quarkus/it/hibernate/processor/data/MyEntityResource.java
Copy file name to clipboardExpand all lines: integration-tests/hibernate-orm-data/src/main/java/io/quarkus/it/hibernate/processor/data/pudefault/MyEntity.java
Copy file name to clipboardExpand all lines: integration-tests/hibernate-orm-data/src/main/java/io/quarkus/it/hibernate/processor/data/pudefault/MyRepository.java
Copy file name to clipboardExpand all lines: integration-tests/hibernate-orm-data/src/test/java/io/quarkus/it/hibernate/processor/data/HibernateOrmDataInGraalIT.java
Copy file name to clipboardExpand all lines: integration-tests/hibernate-orm-data/src/test/java/io/quarkus/it/hibernate/processor/data/HibernateOrmDataTest.java
0 commit comments