JPA Interview Questions and Answers
Prepare for your Interview today!
public Category findByCategoryId(Long categoryId) {
try {
logger.info("Enter - findByCategoryId()");
Query lQuery = (Query) em.createNamedQuery("Category.findByCategoryId");
Integer intValue = categoryId.intValue();
lQuery.setParameter("categoryId", intValue);
Category category = (Category) lQuery.getSingleResult();
logger.info("Exit - findByCategoryId");
return category;
} catch (PersistenceException exception) {
logger.debug(exception.getCause().getStackTrace());
logger.error("CategoryDaoImpl::maxCategoryId()::REASON OF EXCEPTION=" + exception.getMessage() + exception.getCause());
} finally {
closeEntityManager();
}
}
Most helpful rated by users: