Closed slin1972 closed 9 years ago
Hello, I'm using this class of JpaRepositoryTest.java for testing:
@Slf4j @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { JpaMySqlConfiguration.class }) public abstract class AbstractJpaTest {
I've changed it, and I have successfully initialized the database.
When I use employeeFindByEmpNo
@Test public void employeeFindByEmpNo() { Employee emp = new Employee(); emp.setName("Sunghyouk Bae"); emp.setEmpNo("21011"); emp = empRepository.saveAndFlush(emp); em.clear();
Employee loaded = empRepository.findByEmpNo(emp.getEmpNo()); assertThat(loaded).isNotNull(); assertThat(loaded).isEqualTo(emp); assertThat(loaded.getUpdatedTimestamp()).isNotNull(); log.debug("Employee=[{}]", loaded); }
the method of repeatedly testing and processing to
empRepository.findByEmpNo (emp.getEmpNo ())
, it always sending SQL statements to the database query, and not from the redis read, this is why?
@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") }) Is this sentence necessary?
Hello, I'm using this class of JpaRepositoryTest.java for testing:
@Slf4j @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(classes = { JpaMySqlConfiguration.class }) public abstract class AbstractJpaTest {
I've changed it, and I have successfully initialized the database.
When I use employeeFindByEmpNo
@Test public void employeeFindByEmpNo() { Employee emp = new Employee(); emp.setName("Sunghyouk Bae"); emp.setEmpNo("21011"); emp = empRepository.saveAndFlush(emp); em.clear();
the method of repeatedly testing and processing to
empRepository.findByEmpNo (emp.getEmpNo ())
, it always sending SQL statements to the database query, and not from the redis read, this is why?