@Transactional(readOnly = true)
public MaterialCategory findUniqueByName(String name)
throws InstanceNotFoundException {
if (StringUtils.isBlank(name)) {
throw new InstanceNotFoundException(null, getEntityClass()
.getName());
}
MaterialCategory materialCategory = (MaterialCategory) getSession()
.createCriteria(MaterialCategory.class).add(
Restrictions.eq("name", name.trim()).ignoreCase())
.uniqueResult();
if (materialCategory == null) {
throw new InstanceNotFoundException(name, getEntityClass().getName());
} else {
return materialCategory;
}
}