use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.
the class HibernateSolicitacaoPlamensDAO method create.
@Override
public Long create(SolicitacaoPlamensDTO solicitacao) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
SolicitacaoPlamens _solicitacao = new SolicitacaoPlamens(solicitacao);
Long solicitacaoId = (Long) session.save(_solicitacao);
return solicitacaoId;
} catch (HibernateException e) {
Logger.getLogger(TreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("solicitacoes.create.error"));
}
}
use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.
the class HibernateSolicitacaoPlamensDAO method findAll.
@SuppressWarnings("unchecked")
@Override
public List<SolicitacaoPlamensDTO> findAll(int ano, Long organizacaoProponenteId, Long organizacaoSolicitanteId) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
Criteria criteria = session.createCriteria(SolicitacaoPlamens.class);
if (ano > 0) {
criteria.add(Restrictions.eq("ano", ano));
}
if (organizacaoProponenteId != null && organizacaoProponenteId > 0L) {
criteria.add(Restrictions.eq("organizacaoProponente.id", organizacaoProponenteId));
}
if (organizacaoSolicitanteId != null && organizacaoSolicitanteId > 0L) {
criteria.add(Restrictions.eq("organizacaoSolicitante.id", organizacaoSolicitanteId));
}
criteria.addOrder(Order.asc("organizacaoSolicitante.id"));
criteria.addOrder(Order.asc("prioridade"));
List<SolicitacaoPlamens> solicitacoes = criteria.list();
List<SolicitacaoPlamensDTO> dto = new ArrayList<SolicitacaoPlamensDTO>();
for (SolicitacaoPlamens solicitacao : solicitacoes) {
dto.add(solicitacao.createDTO());
}
return dto;
} catch (HibernateException e) {
Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("solicitacoes.find.list.error"));
}
}
use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.
the class HibernateSolicitacaoPlamensDAO method update.
@Override
public void update(SolicitacaoPlamensDTO solicitacao) throws DAOException {
Session session = sessionFactory.getCurrentSession();
SolicitacaoPlamens _solicitacao = new SolicitacaoPlamens(solicitacao);
try {
session.update(_solicitacao);
} catch (HibernateException e) {
Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("solicitacoes.update.error"));
}
}
use of com.tomasio.projects.trainning.model.SolicitacaoPlamens in project trainning by fernandotomasio.
the class HibernateSolicitacaoPlamensDAO method remove.
@Override
public void remove(Long id) throws DAOException {
Session session = sessionFactory.getCurrentSession();
try {
SolicitacaoPlamens solicitacao = (SolicitacaoPlamens) session.get(SolicitacaoPlamens.class, id);
session.delete(solicitacao);
} catch (HibernateException e) {
Logger.getLogger(HibernateTreinamentoSolicitadoDAO.class.getName()).log(Level.SEVERE, null, e);
throw new DAOException(MessageHelper.getMessage("solicitacoes.remove.error"));
}
}
Aggregations