DATACMNS-20 - Adapted refactoring of findById(…) to findOne(…).
This commit is contained in:
@@ -70,7 +70,7 @@ public interface JpaRepository<T, ID extends Serializable> extends
|
||||
* org.springframework.data.repository.Repository#findById(java.io.Serializable
|
||||
* )
|
||||
*/
|
||||
T findById(ID id);
|
||||
T findOne(ID id);
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -165,7 +165,7 @@ public class SimpleJpaRepository<T, ID extends Serializable> implements
|
||||
* org.springframework.data.repository.Repository#readById(java.io.Serializable
|
||||
* )
|
||||
*/
|
||||
public T findById(ID id) {
|
||||
public T findOne(ID id) {
|
||||
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return em.find(getDomainClass(), id);
|
||||
@@ -182,7 +182,7 @@ public class SimpleJpaRepository<T, ID extends Serializable> implements
|
||||
public boolean exists(ID id) {
|
||||
|
||||
Assert.notNull(id, "The given id must not be null!");
|
||||
return null != findById(id);
|
||||
return null != findOne(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,6 +63,6 @@ public class RoleRepositoryIntegrationTests {
|
||||
ReflectionTestUtils.setField(reference, "name", "USER");
|
||||
repository.save(reference);
|
||||
|
||||
assertThat(repository.findById(result.getId()), is(reference));
|
||||
assertThat(repository.findOne(result.getId()), is(reference));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
User foundPerson = repository.findById(id);
|
||||
User foundPerson = repository.findOne(id);
|
||||
assertEquals(firstUser.getFirstname(), foundPerson.getFirstname());
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
assertNull(repository.findById(id * 27));
|
||||
assertNull(repository.findOne(id * 27));
|
||||
}
|
||||
|
||||
|
||||
@@ -170,10 +170,10 @@ public class UserRepositoryTests {
|
||||
|
||||
flushTestUsers();
|
||||
|
||||
User foundPerson = repository.findById(id);
|
||||
User foundPerson = repository.findOne(id);
|
||||
foundPerson.setLastname("Schlicht");
|
||||
|
||||
User updatedPerson = repository.findById(id);
|
||||
User updatedPerson = repository.findOne(id);
|
||||
assertEquals(foundPerson.getFirstname(), updatedPerson.getFirstname());
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
repository.delete(firstUser);
|
||||
assertNull(repository.findById(id));
|
||||
assertNull(repository.findOne(id));
|
||||
}
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ public class UserRepositoryTests {
|
||||
flushTestUsers();
|
||||
|
||||
// Fetches first user from database
|
||||
User firstReferenceUser = repository.findById(firstUser.getId());
|
||||
User firstReferenceUser = repository.findOne(firstUser.getId());
|
||||
assertEquals(firstUser, firstReferenceUser);
|
||||
|
||||
// Fetch colleagues and assert link
|
||||
@@ -401,7 +401,7 @@ public class UserRepositoryTests {
|
||||
firstUser.addColleague(new User("Florian", "Hopf", "hopf@synyx.de"));
|
||||
firstUser = repository.save(firstUser);
|
||||
|
||||
User reference = repository.findById(firstUser.getId());
|
||||
User reference = repository.findOne(firstUser.getId());
|
||||
Set<User> colleagues = reference.getColleagues();
|
||||
|
||||
assertNotNull(colleagues);
|
||||
|
||||
@@ -80,7 +80,7 @@ public class CustomRepositoryFactoryConfigTests {
|
||||
@Test
|
||||
public void reconfiguresTransactionalMethodWithGenericParameter() {
|
||||
|
||||
userRepository.findById(1);
|
||||
userRepository.findOne(1);
|
||||
|
||||
assertFalse(transactionManager.getDefinition().isReadOnly());
|
||||
assertThat(transactionManager.getDefinition().getTimeout(), is(10));
|
||||
|
||||
@@ -42,6 +42,6 @@ public interface UserCustomExtendedRepository extends
|
||||
|
||||
|
||||
@Transactional(readOnly = false, timeout = 10)
|
||||
User findById(Integer id);
|
||||
User findOne(Integer id);
|
||||
|
||||
}
|
||||
@@ -54,11 +54,11 @@ public interface UserRepository extends JpaRepository<User, Integer>,
|
||||
|
||||
|
||||
/**
|
||||
* Redeclaration of {@link Repository#findById(java.io.Serializable)} to
|
||||
* Redeclaration of {@link Repository#findOne(java.io.Serializable)} to
|
||||
* change transaction configuration.
|
||||
*/
|
||||
@Transactional
|
||||
public User findById(Integer primaryKey);
|
||||
public User findOne(Integer primaryKey);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JpaRepositoryTests {
|
||||
SampleEntity entity = new SampleEntity("foo", "bar");
|
||||
repository.saveAndFlush(entity);
|
||||
assertThat(repository.count(), is(1L));
|
||||
assertThat(repository.findById(new SampleEntityPK("foo", "bar")),
|
||||
assertThat(repository.findOne(new SampleEntityPK("foo", "bar")),
|
||||
is(entity));
|
||||
|
||||
repository.delete(Arrays.asList(entity));
|
||||
|
||||
@@ -90,7 +90,7 @@ public class TransactionalRepositoryTests extends
|
||||
@Test
|
||||
public void invokeRedeclaredMethod() throws Exception {
|
||||
|
||||
repository.findById(1);
|
||||
repository.findOne(1);
|
||||
assertFalse(transactionManager.getDefinition().isReadOnly());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user