本文主要是介绍CrudRepository中不见merge或update的踪影,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
看CrudRepository接口,进去一看,说好的crud,可是怎么不见merge或update呢?
再一看save注释:
- /**
- * Saves a given entity. Use the returned instance for further operations as the save operation might have changed the
- * entity instance completely.
- *
- * @param entity
- * @return the saved entity
- */
- <S extends T> S save(S entity);
这。。。
点进去看一看有哪些实现。。。
只有SimpleJpaRepository中的实现:
- /*
- * (non-Javadoc)
- * @see org.springframework.data.repository.CrudRepository#save(java.lang.Object)
- */
- @Transactional
- public <S extends T> S save(S entity) {
- if (entityInformation.isNew(entity)) {
- em.persist(entity);
- return entity;
- } else {
- return em.merge(entity);
- }
- }
这篇关于CrudRepository中不见merge或update的踪影的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!