jpa findone 和 getone的区别
来源:互联网 发布:三字头中华 知乎 编辑:程序博客网 时间:2024/06/05 05:42
注意getOne是“Returns a reference“findOne比getOne更通用。推荐使用findOne。具体原因如下:it's just that/** * Retrieves an entity by its id. * * @param id must not be {@literal null}. * @return the entity with the given id or {@literal null} if none found * @throws IllegalArgumentException if {@code id} is {@literal null} */ T findOne(ID id);/** * Returns a reference to the entity with the given identifier. * * @param id must not be {@literal null}. * @return a reference to the entity with the given identifier. * @see EntityManager#getReference(Class, Object) */ T getOne(ID id);
findOne(ID)
is more generic than the more specialisedgetOne(ID)
. Which one you use is up to you and your project but I would personally stick to thefindOne(ID)
as it makes your code less implementation specific and opens the doors to move to things like MongoDB etc. in the future without too much refactoring :) 欢迎关注橙子博客微信公众号:chengziboke888
查看原文:http://zccbbg.top/2017/05/24/111-2/
阅读全文
0 0
- jpa findone 和 getone的区别
- spring-data-jpa中findOne与getOne的区别
- spring-data-jpa中findOne与getOne的区别
- spring-data-jpa中findOne与getOne的区别
- spring-data-jpa中findOne与getOne的区别
- 关于MongoDB中,find()和findOne()的区别
- ecshop的数据库getRow、getAll、getOne区别
- ecshop的数据库getRow、getAll、getOne区别
- JPA和Hibernate的区别
- JPA和Hibernate的区别
- JPA和Hibernate的区别
- JPA和Hibernate的区别
- JPA和Hibernate的区别
- JPA和Hibernate的区别
- yii2中findOne的用法
- Hibernate和Spring data jpa的区别?
- EC getRow、getAll、getOne……区别
- 从spring jpa getone 说到 Hibernate中的动态代理Javassist
- JavaScript中的数组
- 学习C的一些笔记(一)
- ubuntu显卡驱动的下载和安装
- 你应该切换到Kotlin开发
- 单链表
- jpa findone 和 getone的区别
- c语言中,关于随机函数的使用详解
- [小技巧]如何让emoji存放到数据库中
- H5基础标签
- 使用maven搭建Spring整合cxf
- 红黑二叉查找树的插入
- 编程总结2
- Python 小甲鱼爬虫代理学习
- 简单工厂、工厂方法、抽象工厂