I used Spring MVC arch, and I need to be informed about correct names of methods and exceptions throwing.
/**
* @author Eugene G. Ustimenko
* @date Jan 19, 2015
*/
@Service
@Qualifier ("entityService")
public class BaseEntityService < T extends BaseEntity > implements IBaseEntityService < T > {
@Autowired
private IBaseEntityDao<T> dao;
@Transactional
@Override
public T create (T entity) throws ServiceException {
try {
return dao.create(entity);
}
catch (final Exception ex) {
throw new ServiceException("Create entity operation error " + ex.getMessage(), ex);
}
}
@Transactional
@Override
public T update (T entity) throws ServiceException {
try {
return dao.update(entity);
}
catch (final Exception ex) {
throw new ServiceException("Update entity operation error " + ex.getMessage(), ex);
}
}
@Transactional
@Override
public void remove (Long id) throws ServiceException {
try {
dao.remove(id);
}
catch (final Exception ex) {
throw new ServiceException("Remove entity operation error " + ex.getMessage(), ex);
}
}
@Override
public List < T > getAll () throws ServiceException {
try {
return dao.getAll();
}
catch (final Exception ex) {
throw new ServiceException("Get list of entities operation error " + ex.getMessage(), ex);
}
}
@Override
public T get (Long id) throws ServiceException {
try {
return dao.get(id);
}
catch (final Exception ex) {
throw new ServiceException("Get entity by identifier operation error" + ex.getMessage(), ex);
}
}
}