debop / hibernate-redis

hibernate 2nd level cache privder using redis
Apache License 2.0
358 stars 182 forks source link

Test problems #38

Closed slin1972 closed 9 years ago

slin1972 commented 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?

slin1972 commented 9 years ago

@QueryHints({ @QueryHint(name = "org.hibernate.cacheable", value = "true") }) Is this sentence necessary?