本文整理匯總了Java中org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException類的典型用法代碼示例。如果您正苦於以下問題:Java HibernateObjectRetrievalFailureException類的具體用法?Java HibernateObjectRetrievalFailureException怎麽用?Java HibernateObjectRetrievalFailureException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HibernateObjectRetrievalFailureException類屬於org.springframework.orm.hibernate3包,在下文中一共展示了HibernateObjectRetrievalFailureException類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: load
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/**
* @param id
* Set the id
* @param fetch
* Set the fetch profile (can be null)
* @return the loaded object
*/
public T load(final Long id, final String fetch) {
Criteria criteria = getSession().createCriteria(type).add(
Restrictions.idEq(id));
enableProfilePreQuery(criteria, fetch);
T t = (T) criteria.uniqueResult();
if (t == null) {
throw new HibernateObjectRetrievalFailureException(
new UnresolvableObjectException(id,
"Object could not be resolved"));
}
enableProfilePostQuery(t, fetch);
return t;
}
示例2: handleObjectNotFoundException
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
@ExceptionHandler(HibernateObjectRetrievalFailureException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
public ModelAndView handleObjectNotFoundException(HibernateObjectRetrievalFailureException orfe) {
ModelAndView modelAndView = new ModelAndView("resourceNotFound");
modelAndView.addObject("exception", orfe);
return modelAndView;
}
示例3: getPostById
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/**
* Retrieve a post by ID.
* <p>
* @param post The post to retrieve.
*/
public Post getPostById(int post)
{
try
{
return (Post) getHibernateTemplate().get(Post.class, new Integer(post));
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
示例4: getBoardById
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/** Retrieve a board by ID.
* <p>
* @param board The board to retrieve.
*/
public Board getBoardById(int board)
{
try
{
return (Board) getHibernateTemplate().get(Board.class, new Integer(board));
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
示例5: getUserById
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/**
* Get a user by id.
* <p>
* @param id The id to use to find the user.
* @return The user with the given id, or null if none.
*/
public User getUserById(int id)
{
try
{
return (User) getHibernateTemplate().get(User.class, new Integer(id));
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
示例6: getForumById
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/** Retrieve a forum by ID.
* <p>
* @param forum The forum to retrieve.
*/
public Forum getForumById(int forum)
{
try
{
return (Forum) getHibernateTemplate().get(Forum.class, new Integer(forum));
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
示例7: getCategoryById
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/** Retrieve a category by ID.
* <p>
* @param category The category to retrieve.
*/
public Category getCategoryById(int category)
{
try
{
return (Category) getHibernateTemplate().get(Category.class, new Integer(category));
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}
示例8: retrieveObjectById
import org.springframework.orm.hibernate3.HibernateObjectRetrievalFailureException; //導入依賴的package包/類
/**
* Convenience method for retrieving an arbitrary class by ID. Casting
* must be performed by the caller.
* <p>
* @param id Unique primary key ID for object to retrieve.
* @param objClass Class of object to retrieve.
* @return Object if found, null otherwise.
*/
protected Object retrieveObjectById(int id, Class objClass)
{
try
{
return getHibernateTemplate().get(objClass, new Integer(id));
}
catch (HibernateObjectRetrievalFailureException e)
{
return null;
}
}