// repository
public interface EmployeeJpaRepo extends JpaRepository<Employee,Integer> {
}
// EmployeeJpaRepoTest
public class EmployeeJpaRepoTest {
private ApplicationContext ctx = null;
private EmployeeJpaRepo employeeJpaRepo = null;
@Before
public void setUp(){
ctx = new ClassPathXmlApplicationContext("bean-new.xml");
employeeJpaRepo = ctx.getBean(EmployeeJpaRepo.class);
System.out.println(" setup is running..... ");
}
@After
public void close(){
ctx = null;
System.out.println(" close is running..... ");
}
@Test
public void findOne(){
Employee employee = employeeJpaRepo.findOne(10);
System.out.println(employee);
//这个方法在JpaRepository接口中有出现,我开始觉得会返回一个Employee对象,结果看返回值是一个抽象类
//那么这个geOne方法放在类里面主要做什么用,该怎么用
employeeJpaRepo.getOne(11);
System.out.println("id102是否存在"+employeeJpaRepo.exists(102));
}
}