Skip to content

Commit 87149b9

Browse files
authored
Merge pull request #935 from njr-11/906-standardize-on-the-term-entity-attribute
standardize on the term entity attribute
2 parents 5be2103 + d82c044 commit 87149b9

18 files changed

+221
-212
lines changed

api/src/main/java/jakarta/data/Sort.java

+50-44
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626
* <p>Requests sorting on a given entity attribute.</p>
2727
*
2828
* <p>An instance of {@code Sort} specifies a sorting criterion based
29-
* on an entity field, with a sorting {@linkplain Direction direction}
29+
* on an entity attribute, with a sorting {@linkplain Direction direction}
3030
* and well-defined case sensitivity.</p>
3131
*
3232
* <p>A query method of a repository may have a parameter or parameters
@@ -83,24 +83,28 @@
8383
* sort criteria.</p>
8484
*
8585
*
86-
* @param <T> entity class of the property upon which to sort.
87-
* @param property name of the property to order by.
88-
* @param isAscending whether ordering for this property is ascending (true) or descending (false).
86+
* @param <T> entity class of the entity attribute upon which to sort.
87+
* @param property name of the entity attribute to order by.
88+
* @param isAscending whether ordering for this attribute is ascending (true) or descending (false).
8989
* @param ignoreCase whether or not to request case insensitive ordering from a database with case sensitive collation.
9090
*/
9191
public record Sort<T>(String property, boolean isAscending, boolean ignoreCase) {
9292

9393
/**
94-
* <p>Defines sort criteria for an entity property. For more descriptive code, use:</p>
94+
* <p>Defines sort criteria for an entity attribute. For more descriptive code, use:</p>
9595
* <ul>
96-
* <li>{@link #asc(String) Sort.asc(propertyName)} for ascending sort on a property.</li>
97-
* <li>{@link #ascIgnoreCase(String) Sort.ascIgnoreCase(propertyName)} for case insensitive ascending sort on a property.</li>
98-
* <li>{@link #desc(String) Sort.desc(propertyName)} for descending sort on a property.</li>
99-
* <li>{@link #descIgnoreCase(String) Sort.descIgnoreCase(propertyName)} for case insensitive descending sort on a property.</li>
96+
* <li>{@link #asc(String) Sort.asc(attributeName)}
97+
* for ascending sort on an entity attribute.</li>
98+
* <li>{@link #ascIgnoreCase(String) Sort.ascIgnoreCase(attributeName)}
99+
* for case insensitive ascending sort on an entity attribute.</li>
100+
* <li>{@link #desc(String) Sort.desc(attributeName)}
101+
* for descending sort on an entity attribute.</li>
102+
* <li>{@link #descIgnoreCase(String) Sort.descIgnoreCase(attributeName)}
103+
* for case insensitive descending sort on an entity attribute.</li>
100104
* </ul>
101105
*
102-
* @param property name of the property to order by.
103-
* @param isAscending whether ordering for this property is ascending (true) or descending (false).
106+
* @param property name of the entity attribute to order by.
107+
* @param isAscending whether ordering for this attribute is ascending (true) or descending (false).
104108
* @param ignoreCase whether or not to request case insensitive ordering from a database with case sensitive collation.
105109
*/
106110
public Sort {
@@ -109,9 +113,9 @@ public record Sort<T>(String property, boolean isAscending, boolean ignoreCase)
109113

110114
// Override to provide method documentation:
111115
/**
112-
* Name of the property to order by.
116+
* Name of the entity attribute to order by.
113117
*
114-
* @return The property name to order by; will never be {@code null}.
118+
* @return The attribute name to order by; will never be {@code null}.
115119
*/
116120
public String property() {
117121
return property;
@@ -124,26 +128,28 @@ public String property() {
124128
* A database with case insensitive collation performs case insensitive
125129
* ordering regardless of the requested {@code ignoreCase} value.</p>
126130
*
127-
* @return Returns whether or not to request case insensitive sorting for the property.
131+
* @return Returns whether or not to request case insensitive sorting for the entity attribute.
128132
*/
129133
public boolean ignoreCase() {
130134
return ignoreCase;
131135
}
132136

133137
// Override to provide method documentation:
134138
/**
135-
* Indicates whether to sort the property in ascending order (true) or descending order (false).
139+
* Indicates whether to sort the entity attribute in ascending order (true)
140+
* or descending order (false).
136141
*
137-
* @return Returns whether sorting for this property shall be ascending.
142+
* @return Returns whether sorting for this attribute shall be ascending.
138143
*/
139144
public boolean isAscending() {
140145
return isAscending;
141146
}
142147

143148
/**
144-
* Indicates whether to sort the property in descending order (true) or ascending order (false).
149+
* Indicates whether to sort the entity attribute in descending order (true)
150+
* or ascending order (false).
145151
*
146-
* @return Returns whether sorting for this property shall be descending.
152+
* @return Returns whether sorting for this attribute shall be descending.
147153
*/
148154
public boolean isDescending() {
149155
return !isAscending;
@@ -152,67 +158,67 @@ public boolean isDescending() {
152158
/**
153159
* Create a {@link Sort} instance
154160
*
155-
* @param <T> entity class of the sortable property.
156-
* @param property the property name to order by
157-
* @param direction the direction in which to order.
161+
* @param <T> entity class of the sortable entity attribute.
162+
* @param attribute name of the entity attribute to order by
163+
* @param direction the direction in which to order.
158164
* @param ignoreCase whether to request a case insensitive ordering.
159165
* @return a {@link Sort} instance. Never {@code null}.
160166
* @throws NullPointerException when there is a null parameter
161167
*/
162-
public static <T> Sort<T> of(String property, Direction direction, boolean ignoreCase) {
168+
public static <T> Sort<T> of(String attribute, Direction direction, boolean ignoreCase) {
163169
Objects.requireNonNull(direction, "direction is required");
164-
return new Sort<>(property, Direction.ASC.equals(direction), ignoreCase);
170+
return new Sort<>(attribute, Direction.ASC.equals(direction), ignoreCase);
165171
}
166172

167173
/**
168174
* Create a {@link Sort} instance with {@link Direction#ASC ascending direction}
169175
* that does not request case insensitive ordering.
170176
*
171-
* @param <T> entity class of the sortable property.
172-
* @param property the property name to order by
177+
* @param <T> entity class of the sortable entity attribute.
178+
* @param attribute name of the entity attribute to order by
173179
* @return a {@link Sort} instance. Never {@code null}.
174-
* @throws NullPointerException when the property is null
180+
* @throws NullPointerException when the attribute name is null
175181
*/
176-
public static <T> Sort<T> asc(String property) {
177-
return new Sort<>(property, true, false);
182+
public static <T> Sort<T> asc(String attribute) {
183+
return new Sort<>(attribute, true, false);
178184
}
179185

180186
/**
181187
* Create a {@link Sort} instance with {@link Direction#ASC ascending direction}
182188
* and case insensitive ordering.
183189
*
184-
* @param <T> entity class of the sortable property.
185-
* @param property the property name to order by.
190+
* @param <T> entity class of the sortable entity attribute.
191+
* @param attribute name of the entity attribute to order by.
186192
* @return a {@link Sort} instance. Never {@code null}.
187-
* @throws NullPointerException when the property is null.
193+
* @throws NullPointerException when the attribute name is null.
188194
*/
189-
public static <T> Sort<T> ascIgnoreCase(String property) {
190-
return new Sort<>(property, true, true);
195+
public static <T> Sort<T> ascIgnoreCase(String attribute) {
196+
return new Sort<>(attribute, true, true);
191197
}
192198

193199
/**
194200
* Create a {@link Sort} instance with {@link Direction#DESC descending direction}
195201
* that does not request case insensitive ordering.
196202
*
197-
* @param <T> entity class of the sortable property.
198-
* @param property the property name to order by
203+
* @param <T> entity class of the sortable entity attribute.
204+
* @param attribute name of the entity attribute to order by
199205
* @return a {@link Sort} instance. Never {@code null}.
200-
* @throws NullPointerException when the property is null
206+
* @throws NullPointerException when the attribute name is null
201207
*/
202-
public static <T> Sort<T> desc(String property) {
203-
return new Sort<>(property, false, false);
208+
public static <T> Sort<T> desc(String attribute) {
209+
return new Sort<>(attribute, false, false);
204210
}
205211

206212
/**
207213
* Create a {@link Sort} instance with {@link Direction#DESC descending direction}
208214
* and case insensitive ordering.
209215
*
210-
* @param <T> entity class of the sortable property.
211-
* @param property the property name to order by.
216+
* @param <T> entity class of the sortable entity attribute.
217+
* @param attribute name of the entity attribute to order by.
212218
* @return a {@link Sort} instance. Never {@code null}.
213-
* @throws NullPointerException when the property is null.
219+
* @throws NullPointerException when the attribute name is null.
214220
*/
215-
public static <T> Sort<T> descIgnoreCase(String property) {
216-
return new Sort<>(property, false, true);
221+
public static <T> Sort<T> descIgnoreCase(String attribute) {
222+
return new Sort<>(attribute, false, true);
217223
}
218224
}

api/src/main/java/jakarta/data/TextRestrictionRecord.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2024,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,12 +34,12 @@ record TextRestrictionRecord<T>(
3434
Objects.requireNonNull(attribute, "Attribute must not be null");
3535
}
3636

37-
TextRestrictionRecord(String field, Operator comparison, boolean escaped, String value) {
38-
this(field, comparison, true, escaped, value);
37+
TextRestrictionRecord(String attributeName, Operator comparison, boolean escaped, String value) {
38+
this(attributeName, comparison, true, escaped, value);
3939
}
4040

41-
TextRestrictionRecord(String field, Operator comparison, String value) {
42-
this(field, comparison, true, false, value);
41+
TextRestrictionRecord(String attributeName, Operator comparison, String value) {
42+
this(attributeName, comparison, true, false, value);
4343
}
4444

4545
@Override

api/src/main/java/jakarta/data/metamodel/StaticMetamodel.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2023,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@
2929
* <p>Annotates a class which serves as a static metamodel for an entity, enabling
3030
* type-safe access to entity attribute names and related objects such as instances
3131
* of {@link Sort}s for an attribute. A metamodel class contains one or more
32-
* {@code public static} fields corresponding to persistent fields of the entity class.
32+
* {@code public static} fields corresponding to attributes of the entity class.
3333
* The type of each of these fields must be either {@link String}, {@link Attribute},
3434
* or a subinterface of {@code Attribute} defined in this package.</p>
3535
*

api/src/main/java/jakarta/data/page/CursoredPage.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,11 +33,11 @@
3333
* inserted, deleted, or updated in the database between page requests.
3434
* Cursor-based pagination is possible when a query result set has a
3535
* well-defined total order, that is, when the results are sorted by a
36-
* list of entity fields which forms a unique key on the result set.
37-
* This list of entity fields must be the entity fields of the combined
36+
* list of entity attributes which forms a unique key on the result set.
37+
* This list of entity attributes must be the entity attributes of the combined
3838
* sort criteria of the repository method, in the same order of precedence.
39-
* This could just be the identifier field of the entity, or it might be
40-
* some other combination of fields which uniquely identifies each query
39+
* This could just be the identifier attribute of the entity, or it might be
40+
* some other combination of entity attributes which uniquely identifies each query
4141
* result.</p>
4242
*
4343
* <p>When cursor-based pagination is used, a {@linkplain #nextPageRequest
@@ -100,14 +100,14 @@
100100
* vulnerable to changes made to data in between page requests. Adding or
101101
* removing entities is possible without causing unexpected missed or
102102
* duplicate results. Cursor-based pagination does not prevent misses and
103-
* duplicates if the entity properties which are the sort criteria for
103+
* duplicates if the entity attributes which are the sort criteria for
104104
* existing entities are modified or if an entity is re-added with different
105105
* sort criteria after having previously been removed.</p>
106106
*
107107
* <h2>Cursor-based Pagination with {@code @Query}</h2>
108108
*
109109
* <p>Cursor-based pagination involves generating and appending additional
110-
* restrictions involving the key fields to the {@code WHERE} clause of the
110+
* restrictions involving the key elements to the {@code WHERE} clause of the
111111
* query. For this to be possible, a user-provided JDQL or JPQL query must
112112
* end with a {@code WHERE} clause to which additional conditions may be
113113
* appended.</p>

api/src/main/java/jakarta/data/repository/BasicRepository.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -186,7 +186,7 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
186186
/**
187187
* Deletes a given entity. Deletion is performed by matching the Id, and if the entity is
188188
* versioned (for example, with {@code jakarta.persistence.Version}), then also the version.
189-
* Other properties of the entity do not need to match.
189+
* Other attributes of the entity do not need to match.
190190
*
191191
* @param entity must not be {@code null}.
192192
* @throws OptimisticLockingFailureException if the entity is not found in the database for deletion
@@ -199,7 +199,7 @@ public interface BasicRepository<T, K> extends DataRepository<T, K> {
199199
/**
200200
* Deletes the given entities. Deletion of each entity is performed by matching the unique identifier,
201201
* and if the entity is versioned (for example, with {@code jakarta.persistence.Version}), then also
202-
* the version. Other properties of the entity do not need to match.
202+
* the version. Other attributes of the entity do not need to match.
203203
*
204204
* @param entities Must not be {@code null}. Must not contain {@code null} elements.
205205
* @throws OptimisticLockingFailureException If an entity is not found in the database for deletion

api/src/main/java/jakarta/data/repository/By.java

+16-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2023,2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2023,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,16 +25,16 @@
2525

2626
/**
2727
* <p>Annotates a parameter of a repository method, specifying a mapping to
28-
* a persistent field:</p>
28+
* an entity attribute:</p>
2929
* <ul>
30-
* <li>if a {@linkplain #value field name} is specified, the parameter maps
31-
* to the persistent field with the specified name, or
30+
* <li>if an {@linkplain #value attribute name} is specified, the parameter maps
31+
* to the entity attribute with the specified name, or
3232
* <li>if the special value {@value #ID} is specified, the parameter maps
33-
* to the unique identifier field or property.
33+
* to the unique identifier attribute.
3434
* </ul>
3535
* <p>Arguments to the annotated parameter are compared to values of the
36-
* mapped persistent field.</p>
37-
* <p>The field name may be a compound name like {@code address.city}.</p>
36+
* mapped attribute.</p>
37+
* <p>The attribute name may be a compound name like {@code address.city}.</p>
3838
*
3939
* <p>For example, for a {@code Person} entity with attributes {@code ssn},
4040
* {@code firstName}, {@code lastName}, and {@code address} we might have:</p>
@@ -84,23 +84,25 @@
8484
public @interface By {
8585

8686
/**
87-
* The name of the persistent field mapped by the annotated parameter,
88-
* or {@value #ID} to indicate the unique identifier field or property
87+
* The name of the entity attribute mapped by the annotated parameter,
88+
* or {@value #ID} to indicate the unique identifier attribute
8989
* of the entity.
9090
*
91-
* @return the persistent field name, or {@value #ID} to indicate the
92-
* unique identifier field.
91+
* @return the entity attribute name, or {@value #ID} to indicate the
92+
* unique identifier attribute.
9393
*/
9494
String value();
9595

9696
/**
97-
* The special value which indicates the unique identifier field or
98-
* property. The annotation {@code By(ID)} maps a parameter to the
99-
* identifier.
97+
* <p>
98+
* The special value which indicates the unique identifier attribute.
99+
* The annotation {@code By(ID)} maps a parameter to the identifier.
100+
* </p>
100101
* <p>
101102
* Note that {@code id(this)} is the expression in JPQL for the
102103
* unique identifier of an entity with an implicit identification
103104
* variable.
105+
* </p>
104106
*/
105107
String ID = "id(this)";
106108
}

api/src/main/java/jakarta/data/repository/CrudRepository.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022,2024 Contributors to the Eclipse Foundation
2+
* Copyright (c) 2022,2025 Contributors to the Eclipse Foundation
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -82,7 +82,7 @@
8282
* <p>The module Javadoc provides an {@link jakarta.data/ overview} of Jakarta Data.</p>
8383
*
8484
* @param <T> the type of the primary entity class of the repository.
85-
* @param <K> the type of the unique identifier field of property of the primary entity.
85+
* @param <K> the type of the unique identifier attribute of the primary entity.
8686
* @see BasicRepository
8787
* @see DataRepository
8888
*/

0 commit comments

Comments
 (0)