fetch 与 find 的区别

liferay中 findxxxx 与fetchxxx 方法区别在于数据不存在时前者抛出异常后者返回Null

 

fetchByPrimaryKey

 

/**

* Returns the product with the primary key or returns <code>null</code> if it could not be found.

*

* @param productId the primary key of the product

* @return the product, or <code>null</code> if a product with the primary key could not be found

* @throws SystemException if a system exception occurred

*/

public Product fetchByPrimaryKey(long productId) throws SystemException 

 

-------------------------------------------------------

findByPrimaryKey

 

/**

* Returns the product with the primary key or throws a {@link com.bluegrid.portlet.product.NoSuchProductException} if it could not be found.

*

* @param productId the primary key of the product

* @return the product

* @throws com.bluegrid.portlet.product.NoSuchProductException if a product with the primary key could not be found

* @throws SystemException if a system exception occurred

*/

public Product findByPrimaryKey(long productId)

throws NoSuchProductException, SystemException {

你可能感兴趣的:(fetch)