33
33
* @author Mark Paluch
34
34
* @author Sander Krabbenborg
35
35
* @author Jesse Wouters
36
+ * @author Greg Turnquist
36
37
*/
37
38
@ NoRepositoryBean
38
39
public interface JpaRepository <T , ID > extends PagingAndSortingRepository <T , ID >, QueryByExampleExecutor <T > {
@@ -96,7 +97,9 @@ public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>,
96
97
* @deprecated Use {@link #deleteAllInBatch(Iterable)} instead.
97
98
*/
98
99
@ Deprecated
99
- default void deleteInBatch (Iterable <T > entities ){deleteAllInBatch (entities );}
100
+ default void deleteInBatch (Iterable <T > entities ) {
101
+ deleteAllInBatch (entities );
102
+ }
100
103
101
104
/**
102
105
* Deletes the given entities in a batch which means it will create a single query. This kind of operation leaves JPAs
@@ -108,7 +111,6 @@ public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>,
108
111
*/
109
112
void deleteAllInBatch (Iterable <T > entities );
110
113
111
-
112
114
/**
113
115
* Deletes the entities identified by the given ids using a single query. This kind of operation leaves JPAs first
114
116
* level cache and the database out of sync. Consider flushing the {@link EntityManager} before calling this method.
@@ -132,7 +134,7 @@ public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>,
132
134
* @param id must not be {@literal null}.
133
135
* @return a reference to the entity with the given identifier.
134
136
* @see EntityManager#getReference(Class, Object) for details on when an exception is thrown.
135
- * @deprecated use {@link JpaRepository#getById (ID)} instead.
137
+ * @deprecated use {@link JpaRepository#getReferenceById (ID)} instead.
136
138
*/
137
139
@ Deprecated
138
140
T getOne (ID id );
@@ -146,10 +148,25 @@ public interface JpaRepository<T, ID> extends PagingAndSortingRepository<T, ID>,
146
148
* @param id must not be {@literal null}.
147
149
* @return a reference to the entity with the given identifier.
148
150
* @see EntityManager#getReference(Class, Object) for details on when an exception is thrown.
151
+ * @deprecated use {@link JpaRepository#getReferenceById(ID)} instead.
149
152
* @since 2.5
150
153
*/
154
+ @ Deprecated
151
155
T getById (ID id );
152
156
157
+ /**
158
+ * Returns a reference to the entity with the given identifier. Depending on how the JPA persistence provider is
159
+ * implemented this is very likely to always return an instance and throw an
160
+ * {@link javax.persistence.EntityNotFoundException} on first access. Some of them will reject invalid identifiers
161
+ * immediately.
162
+ *
163
+ * @param id must not be {@literal null}.
164
+ * @return a reference to the entity with the given identifier.
165
+ * @see EntityManager#getReference(Class, Object) for details on when an exception is thrown.
166
+ * @since 2.7
167
+ */
168
+ T getReferenceById (ID id );
169
+
153
170
/*
154
171
* (non-Javadoc)
155
172
* @see org.springframework.data.repository.query.QueryByExampleExecutor#findAll(org.springframework.data.domain.Example)
0 commit comments