您好,欢迎来到二三娱乐。
搜索
您的当前位置:首页Spring Data JPA getOne()和findOne

Spring Data JPA getOne()和findOne

来源:二三娱乐

使用getOne()获取的是一个空的对象;用findOne则可以获取想要的;
参见源码

/**
 * 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);

/**
 * 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);

Copyright © 2019- yule263.com 版权所有 湘ICP备2023023988号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务