@Override
@Transactional(readOnly = true)
public E findByCode(String code) throws InstanceNotFoundException {
if (StringUtils.isBlank(code)) {
throw new InstanceNotFoundException(null,
getEntityClass().getName());
}
E entity = (E) getSession().createCriteria(getEntityClass()).add(
Restrictions.eq("code", code.trim()).ignoreCase()).uniqueResult();
if (entity == null) {
throw new InstanceNotFoundException(
code, getEntityClass().getName());
} else {
return entity;
}