JpaRepository
- 提供了JPA相关功能
List<T> findAll(); //查找所有实体
List<T> findAll(Sort sort); //排序、查找所有实体
List<T> save(Iterable<? extends T> entities);//保存集合
void flush();//执行缓存与数据库同步
T saveAndFlush(T entity);//强制执行持久化
void deleteInBatch(Iterable<T> entities);//删除一个实体集合
@Test
public void testJpaRepository(){
Person person = new Person();
person.setBrith(new Date());
person.setEmail("XXX@guigu.com");
person.setName("xcv");
//person.setId(3);
//当数据不存在即不设置id时 执行添加操作
personRepsotory.saveAndFlush(person);
}