|
17 | 17 | /// the primary key of an entity class is a surrogate key, that is, |
18 | 18 | /// a {@linkplain jakarta.persistence.GeneratedValue system-generated} |
19 | 19 | /// synthetic identifier, with no domain-model semantics. There should |
20 | | -/// always be some other field or combination of fields which uniquely |
| 20 | +/// always be some other field or combination of fields that uniquely |
21 | 21 | /// identifies an instance of the entity from the point of view of the |
22 | 22 | /// user of the system. This is the _natural id_ of the entity. |
23 | 23 | /// |
|
76 | 76 | /// The [org.hibernate.Session] interface offers several methods |
77 | 77 | /// that allow retrieval of one or more entity references by natural-id |
78 | 78 | /// allow an entity instance to be retrieved by its natural-id: |
79 | | -/// * [org.hibernate.Session#findByNaturalId] allows loading a single |
80 | | -/// entity instance by natural-id. |
81 | | -/// * [org.hibernate.Session#findMultipleByNaturalId] allows loading multiple |
82 | | -/// entity instances by natural-id. |
| 79 | +/// * [org.hibernate.Session#find(Class, Object, jakarta.persistence.FindOption...)] |
| 80 | +/// allows loading a single entity instance by natural-id. |
| 81 | +/// * [org.hibernate.Session#findMultiple(Class, java.util.List, jakarta.persistence.FindOption...)] |
| 82 | +/// allows loading multiple entity instances by natural-id. |
| 83 | +/// |
| 84 | +/// ``` |
| 85 | +/// Person person = session.find(Person.class, ssn, KeyType.NATURAL); |
| 86 | +/// ``` |
| 87 | +/// ``` |
| 88 | +/// Vehicle vehicle = |
| 89 | +/// session.find(Vehicle.class, |
| 90 | +/// Map.of(Vehicle_.REGION, region, |
| 91 | +/// Vehicle_.REGISTRATION, registration), |
| 92 | +/// KeyType.NATURAL); |
| 93 | +/// ``` |
| 94 | +/// ``` |
| 95 | +/// List<Person> people = session.findMultiple(Person.class, ssns, KeyType.NATURAL); |
| 96 | +/// ``` |
83 | 97 | /// |
84 | 98 | /// If the entity is also marked for [natural id caching][NaturalIdCache], |
85 | 99 | /// then these methods may be able to avoid a database round trip. |
86 | 100 | /// |
87 | | -/// @see org.hibernate.Session#findByNaturalId |
88 | | -/// @see org.hibernate.Session#findMultipleByNaturalId |
| 101 | +/// @see org.hibernate.Session#find(Class, Object, jakarta.persistence.FindOption...) |
| 102 | +/// @see org.hibernate.Session#findMultiple(Class, java.util.List, jakarta.persistence.FindOption...) |
89 | 103 | /// @see NaturalIdClass |
90 | 104 | /// @see NaturalIdCache |
91 | 105 | /// |
92 | 106 | /// @apiNote For non-aggregated composite natural-id cases, it is recommended to |
93 | 107 | /// leverage [@NaturalIdClass][NaturalIdClass] for loading. |
| 108 | +/// ``` |
| 109 | +/// Vehicle vehicle = |
| 110 | +/// session.find(Vehicle.class, |
| 111 | +/// VehicleKey(region, registration), |
| 112 | +/// KeyType.NATURAL); |
| 113 | +/// ``` |
94 | 114 | /// |
95 | 115 | /// @author Nicolás Lichtmaier |
96 | 116 | @Target({METHOD, FIELD}) |
|
0 commit comments