List of usage examples for org.hibernate Criteria uniqueResult
public Object uniqueResult() throws HibernateException;
From source file:classes.LoginAction.java
License:Apache License
public String execute() throws Exception { logger.info("Starting execute()"); //f:log Session sess = HibernateUtil.getSessionFactory().openSession(); //f:hibernate Transaction t = sess.beginTransaction(); //f:hibernate Criteria criteria = sess.createCriteria(User.class); //f:hibernate criteria.add(Restrictions.idEq(this.user.getUsername())); //f:hibernate criteria.add(Restrictions.eq("password", this.user.getPassword())); //f:hibernate User user = (User) criteria.uniqueResult(); //f:hibernate t.commit(); //f:hibernate sess.close(); //f:hibernate if (user != null) { ActionContext.getContext().getSession().put(SystemConstants.AUTHENTICATED_USER, user); logger.info("Finishing execute() -- Success"); //f:log return SUCCESS; }/*w ww . j a v a 2s.com*/ this.addActionError(this.getText("login.failure")); logger.info("Finishing execute() -- Failure"); //f:log return INPUT; }
From source file:cn.com.jandar.lawyer.service.LawFirmService.java
public LawFirm findById(String id) { Criteria c = lawFirmDao.getSession().createCriteria(LawFirm.class); c.add(Restrictions.eq("id", id)); return (LawFirm) c.uniqueResult(); }
From source file:cn.com.jandar.lawyer.service.LawFirmService.java
/** * ???/*from w w w . jav a2 s. c o m*/ * @param licenseNumber * @return */ public LawFirm findByLicenseNumber(String licenseNumber) { Criteria c = lawFirmDao.getSession().createCriteria(LawFirm.class); c.add(Restrictions.eq("licenseNumber", licenseNumber)); return (LawFirm) c.uniqueResult(); }
From source file:cn.com.jandar.lawyer.service.LawyerService.java
/** * ?id /*from w ww . j av a 2 s.co m*/ * @param id * @return */ public Lawyer findById(String id) { Criteria c = lawyerDao.getSession().createCriteria(Lawyer.class); c.add(Restrictions.eq("id", id)); return (Lawyer) c.uniqueResult(); }
From source file:cn.com.jandar.lawyer.service.LawyerService.java
/** * ???// w ww .j a v a 2 s. c o m * @param licenseNumber * @return */ public Lawyer findByLicenseNumber(String licenseNumber) { Criteria c = lawyerDao.getSession().createCriteria(Lawyer.class); c.add(Restrictions.eq("licenseNumber", licenseNumber)); return (Lawyer) c.uniqueResult(); }
From source file:cn.com.jandar.lawyer.service.LawyerService.java
/** * ???//from w ww . j a v a2 s . c o m * @param idNumber * @return */ public Lawyer findByIdNumber(String idNumber) { Criteria c = lawyerDao.getSession().createCriteria(Lawyer.class); c.add(Restrictions.eq("idNumber", idNumber)); return (Lawyer) c.uniqueResult(); }
From source file:cn.dayuanzi.dao.BaseDao.java
License:Apache License
/** * ??/* w w w . j a v a 2 s. c om*/ * @param criterions * @return */ public long count(final Criterion... criterions) { Criteria criteria = createCriteria(criterions); criteria.setProjection(Projections.rowCount()); return (long) criteria.uniqueResult(); }
From source file:co.com.codesoftware.logic.admin.ConteosLogic.java
public Integer selectMaxProductoConteo() { Integer resultado = 1;/*from www . ja v a 2 s . c o m*/ try { Criteria crit = sesion.createCriteria(ProductoConteoEntity.class).setProjection(Projections.max("id")); resultado = (Integer) crit.uniqueResult() + 1; } catch (Exception e) { resultado = 1; e.printStackTrace(); } return resultado; }
From source file:co.com.codesoftware.logic.admin.ConteosLogic.java
/** * funcion que consulta un producto especifico del conteo * @param conteo/* www . j ava2 s.c om*/ * @param codigoExteno * @return */ public ProductoConteoEntityTR consultaProductoConteo(Integer conteo, String codigoExterno) { ProductoConteoEntityTR rta = new ProductoConteoEntityTR(); try { ProductoConteoEntity entity = new ProductoConteoEntity(); initOperation(); Criteria crit = sesion.createCriteria(ProductoConteoEntity.class).createAlias("conteo", "con") .createAlias("producto", "prd").add(Restrictions.eq("con.id", conteo)) .add(Restrictions.eq("prd.codigoExt", codigoExterno)); entity = (ProductoConteoEntity) crit.uniqueResult(); rta = transformer(entity); } catch (Exception e) { e.printStackTrace(); rta.setMensaje(e.toString()); } return rta; }
From source file:co.com.codesoftware.logic.MarcaLogic.java
/** * Funcion que consulta el maximo del id de la marca y le suma 1 * @return //from w w w. jav a 2s. co m */ public Integer selectMaxMarca() { Integer resultado = null; try { Criteria crit = sesion.createCriteria(MarcaEntity.class).setProjection(Projections.max("id")); resultado = (Integer) crit.uniqueResult() + 1; } catch (Exception e) { resultado = 1; e.printStackTrace(); } return resultado; }