@@ -99,7 +99,7 @@ public class SimpleJpaRepository<T, ID> implements JpaRepositoryImplementation<T
9999 private static final String ID_MUST_NOT_BE_NULL = "The given id must not be null" ;
100100
101101 private final JpaEntityInformation <T , ?> entityInformation ;
102- private final EntityManager em ;
102+ private final EntityManager entityManager ;
103103 private final PersistenceProvider provider ;
104104
105105 private @ Nullable CrudMethodMetadata metadata ;
@@ -117,18 +117,18 @@ public SimpleJpaRepository(JpaEntityInformation<T, ?> entityInformation, EntityM
117117 Assert .notNull (entityManager , "EntityManager must not be null" );
118118
119119 this .entityInformation = entityInformation ;
120- this .em = entityManager ;
120+ this .entityManager = entityManager ;
121121 this .provider = PersistenceProvider .fromEntityManager (entityManager );
122122 }
123123
124124 /**
125125 * Creates a new {@link SimpleJpaRepository} to manage objects of the given domain type.
126126 *
127127 * @param domainClass must not be {@literal null}.
128- * @param em must not be {@literal null}.
128+ * @param entityManager must not be {@literal null}.
129129 */
130- public SimpleJpaRepository (Class <T > domainClass , EntityManager em ) {
131- this (JpaEntityInformationSupport .getEntityInformation (domainClass , em ), em );
130+ public SimpleJpaRepository (Class <T > domainClass , EntityManager entityManager ) {
131+ this (JpaEntityInformationSupport .getEntityInformation (domainClass , entityManager ), entityManager );
132132 }
133133
134134 /**
@@ -188,14 +188,14 @@ public void delete(T entity) {
188188
189189 Class <?> type = ProxyUtils .getUserClass (entity );
190190
191- T existing = (T ) em .find (type , entityInformation .getId (entity ));
191+ T existing = (T ) entityManager .find (type , entityInformation .getId (entity ));
192192
193193 // if the entity to be deleted doesn't exist, delete is a NOOP
194194 if (existing == null ) {
195195 return ;
196196 }
197197
198- em .remove (em .contains (entity ) ? entity : em .merge (entity ));
198+ entityManager .remove (entityManager .contains (entity ) ? entity : entityManager .merge (entity ));
199199 }
200200
201201 @ Override
@@ -230,7 +230,7 @@ public void deleteAllByIdInBatch(Iterable<ID> ids) {
230230 String queryString = String .format (DELETE_ALL_QUERY_BY_ID_STRING , entityInformation .getEntityName (),
231231 entityInformation .getIdAttribute ().getName ());
232232
233- Query query = em .createQuery (queryString );
233+ Query query = entityManager .createQuery (queryString );
234234
235235 /*
236236 * Some JPA providers require {@code ids} to be a {@link Collection} so we must convert if it's not already.
@@ -271,7 +271,8 @@ public void deleteAllInBatch(Iterable<T> entities) {
271271 return ;
272272 }
273273
274- applyAndBind (getQueryString (DELETE_ALL_QUERY_STRING , entityInformation .getEntityName ()), entities , em )
274+ applyAndBind (getQueryString (DELETE_ALL_QUERY_STRING , entityInformation .getEntityName ()), entities ,
275+ entityManager )
275276 .executeUpdate ();
276277 }
277278
@@ -288,7 +289,7 @@ public void deleteAll() {
288289 @ Transactional
289290 public void deleteAllInBatch () {
290291
291- Query query = em .createQuery (getDeleteAllQueryString ());
292+ Query query = entityManager .createQuery (getDeleteAllQueryString ());
292293
293294 applyQueryHints (query );
294295
@@ -303,13 +304,13 @@ public Optional<T> findById(ID id) {
303304 Class <T > domainType = getDomainClass ();
304305
305306 if (metadata == null ) {
306- return Optional .ofNullable (em .find (domainType , id ));
307+ return Optional .ofNullable (entityManager .find (domainType , id ));
307308 }
308309
309310 LockModeType type = metadata .getLockModeType ();
310311 Map <String , Object > hints = getHints ();
311312
312- return Optional .ofNullable (type == null ? em .find (domainType , id , hints ) : em .find (domainType , id , type , hints ));
313+ return Optional .ofNullable (type == null ? entityManager .find (domainType , id , hints ) : entityManager .find (domainType , id , type , hints ));
313314 }
314315
315316 @ Deprecated
@@ -332,7 +333,7 @@ public T getById(ID id) {
332333 public T getReferenceById (ID id ) {
333334
334335 Assert .notNull (id , ID_MUST_NOT_BE_NULL );
335- return em .getReference (getDomainClass (), id );
336+ return entityManager .getReference (getDomainClass (), id );
336337 }
337338
338339 @ Override
@@ -349,7 +350,7 @@ public boolean existsById(ID id) {
349350 Iterable <String > idAttributeNames = entityInformation .getIdAttributeNames ();
350351 String existsQuery = QueryUtils .getExistsQueryString (entityName , placeholder , idAttributeNames );
351352
352- TypedQuery <Long > query = em .createQuery (existsQuery , Long .class );
353+ TypedQuery <Long > query = entityManager .createQuery (existsQuery , Long .class );
353354
354355 applyQueryHints (query );
355356
@@ -456,20 +457,20 @@ public List<T> findAll(Specification<T> spec, Sort sort) {
456457 @ Override
457458 public boolean exists (Specification <T > spec ) {
458459
459- CriteriaQuery <Integer > cq = this .em .getCriteriaBuilder () //
460+ CriteriaQuery <Integer > cq = this .entityManager .getCriteriaBuilder () //
460461 .createQuery (Integer .class ) //
461- .select (this .em .getCriteriaBuilder ().literal (1 ));
462+ .select (this .entityManager .getCriteriaBuilder ().literal (1 ));
462463
463464 applySpecificationToCriteria (spec , getDomainClass (), cq );
464465
465- TypedQuery <Integer > query = applyRepositoryMethodMetadata (this .em .createQuery (cq ));
466+ TypedQuery <Integer > query = applyRepositoryMethodMetadata (this .entityManager .createQuery (cq ));
466467 return query .setMaxResults (1 ).getResultList ().size () == 1 ;
467468 }
468469
469470 @ Override
470471 public long delete (Specification <T > spec ) {
471472
472- CriteriaBuilder builder = this .em .getCriteriaBuilder ();
473+ CriteriaBuilder builder = this .entityManager .getCriteriaBuilder ();
473474 CriteriaDelete <T > delete = builder .createCriteriaDelete (getDomainClass ());
474475
475476 if (spec != null ) {
@@ -480,7 +481,7 @@ public long delete(Specification<T> spec) {
480481 }
481482 }
482483
483- return this .em .createQuery (delete ).executeUpdate ();
484+ return this .entityManager .createQuery (delete ).executeUpdate ();
484485 }
485486
486487 @ Override
@@ -522,7 +523,7 @@ private <S extends T, R> R doFindBy(Specification<T> spec, Class<T> domainClass,
522523 SpecificationScrollDelegate <T > scrollDelegate = new SpecificationScrollDelegate <>(scrollFunction ,
523524 entityInformation );
524525 FetchableFluentQuery <T > fluentQuery = new FetchableFluentQueryBySpecification <>(spec , domainClass , finder ,
525- scrollDelegate , this ::count , this ::exists , this .em );
526+ scrollDelegate , this ::count , this ::exists , this .entityManager );
526527
527528 return queryFunction .apply ((FetchableFluentQuery <S >) fluentQuery );
528529 }
@@ -549,13 +550,13 @@ public <S extends T> long count(Example<S> example) {
549550 public <S extends T > boolean exists (Example <S > example ) {
550551
551552 Specification <S > spec = new ExampleSpecification <>(example , this .escapeCharacter );
552- CriteriaQuery <Integer > cq = this .em .getCriteriaBuilder () //
553+ CriteriaQuery <Integer > cq = this .entityManager .getCriteriaBuilder () //
553554 .createQuery (Integer .class ) //
554- .select (this .em .getCriteriaBuilder ().literal (1 ));
555+ .select (this .entityManager .getCriteriaBuilder ().literal (1 ));
555556
556557 applySpecificationToCriteria (spec , example .getProbeType (), cq );
557558
558- TypedQuery <Integer > query = applyRepositoryMethodMetadata (this .em .createQuery (cq ));
559+ TypedQuery <Integer > query = applyRepositoryMethodMetadata (this .entityManager .createQuery (cq ));
559560 return query .setMaxResults (1 ).getResultList ().size () == 1 ;
560561 }
561562
@@ -595,7 +596,7 @@ public <S extends T, R> R findBy(Example<S> example, Function<FetchableFluentQue
595596 @ Override
596597 public long count () {
597598
598- TypedQuery <Long > query = em .createQuery (getCountQueryString (), Long .class );
599+ TypedQuery <Long > query = entityManager .createQuery (getCountQueryString (), Long .class );
599600
600601 applyQueryHintsForCount (query );
601602
@@ -614,10 +615,10 @@ public <S extends T> S save(S entity) {
614615 Assert .notNull (entity , "Entity must not be null" );
615616
616617 if (entityInformation .isNew (entity )) {
617- em .persist (entity );
618+ entityManager .persist (entity );
618619 return entity ;
619620 } else {
620- return em .merge (entity );
621+ return entityManager .merge (entity );
621622 }
622623 }
623624
@@ -659,7 +660,7 @@ public <S extends T> List<S> saveAllAndFlush(Iterable<S> entities) {
659660 @ Transactional
660661 @ Override
661662 public void flush () {
662- em .flush ();
663+ entityManager .flush ();
663664 }
664665
665666 /**
@@ -742,7 +743,7 @@ protected TypedQuery<T> getQuery(@Nullable Specification<T> spec, Sort sort) {
742743 */
743744 protected <S extends T > TypedQuery <S > getQuery (@ Nullable Specification <S > spec , Class <S > domainClass , Sort sort ) {
744745
745- CriteriaBuilder builder = em .getCriteriaBuilder ();
746+ CriteriaBuilder builder = entityManager .getCriteriaBuilder ();
746747 CriteriaQuery <S > query = builder .createQuery (domainClass );
747748
748749 Root <S > root = applySpecificationToCriteria (spec , domainClass , query );
@@ -752,7 +753,7 @@ protected <S extends T> TypedQuery<S> getQuery(@Nullable Specification<S> spec,
752753 query .orderBy (toOrders (sort , root , builder ));
753754 }
754755
755- return applyRepositoryMethodMetadata (em .createQuery (query ));
756+ return applyRepositoryMethodMetadata (entityManager .createQuery (query ));
756757 }
757758
758759 /**
@@ -774,7 +775,7 @@ protected TypedQuery<Long> getCountQuery(@Nullable Specification<T> spec) {
774775 */
775776 protected <S extends T > TypedQuery <Long > getCountQuery (@ Nullable Specification <S > spec , Class <S > domainClass ) {
776777
777- CriteriaBuilder builder = em .getCriteriaBuilder ();
778+ CriteriaBuilder builder = entityManager .getCriteriaBuilder ();
778779 CriteriaQuery <Long > query = builder .createQuery (Long .class );
779780
780781 Root <S > root = applySpecificationToCriteria (spec , domainClass , query );
@@ -788,7 +789,7 @@ protected <S extends T> TypedQuery<Long> getCountQuery(@Nullable Specification<S
788789 // Remove all Orders the Specifications might have applied
789790 query .orderBy (Collections .emptyList ());
790791
791- return applyRepositoryMethodMetadataForCount (em .createQuery (query ));
792+ return applyRepositoryMethodMetadataForCount (entityManager .createQuery (query ));
792793 }
793794
794795 /**
@@ -825,7 +826,7 @@ private <S, U extends T> Root<U> applySpecificationToCriteria(@Nullable Specific
825826 return root ;
826827 }
827828
828- CriteriaBuilder builder = em .getCriteriaBuilder ();
829+ CriteriaBuilder builder = entityManager .getCriteriaBuilder ();
829830 Predicate predicate = spec .toPredicate (root , query , builder );
830831
831832 if (predicate != null ) {
@@ -855,7 +856,7 @@ private void applyQueryHints(Query query) {
855856 return ;
856857 }
857858
858- getQueryHints ().withFetchGraphs (em ).forEach (query ::setHint );
859+ getQueryHints ().withFetchGraphs (entityManager ).forEach (query ::setHint );
859860 applyComment (metadata , query ::setHint );
860861 }
861862
@@ -884,7 +885,7 @@ private Map<String, Object> getHints() {
884885
885886 Map <String , Object > hints = new HashMap <>();
886887
887- getQueryHints ().withFetchGraphs (em ).forEach (hints ::put );
888+ getQueryHints ().withFetchGraphs (entityManager ).forEach (hints ::put );
888889
889890 if (metadata != null ) {
890891 applyComment (metadata , hints ::put );
0 commit comments