List of usage examples for org.hibernate Session get
Object get(String entityName, Serializable id);
From source file:biomart.DAO.AdminDAO.java
public String UpdateDeliveryStatus(String orderId, String deliveryType, String deliveryDescription) { Session session = Util.getSessionFactory().openSession(); OrderBean orderBean = (OrderBean) session.get(OrderBean.class, orderId); orderBean.setDeliveryType(deliveryType); orderBean.setDeliveryDescription(deliveryDescription); session.close();// www.j a v a 2s . c om if (new CommonDAO().addOrUpdateDetails(orderBean).equals("success")) { return "success"; } return null; }
From source file:biomart.DAO.AdminDAO.java
public String acceptReference(String referenceId) { Session session = Util.getSessionFactory().openSession(); ReferenceBean referenceBean = (ReferenceBean) session.get(ReferenceBean.class, referenceId); PersonalDetailsBean personalDetailsBean = new PersonalDetailsBean(); personalDetailsBean.setUserName(referenceBean.getName()); personalDetailsBean.setType("S"); personalDetailsBean.setStoreName(referenceBean.getStoreName()); personalDetailsBean.setPhoneNo(referenceBean.getPhoneNo()); personalDetailsBean.setEmailId(referenceBean.getEmail()); PaddressBean paddressBean = new PaddressBean(); paddressBean.setCity(referenceBean.getRaddressBean().getCity()); paddressBean.setDistrict(referenceBean.getRaddressBean().getDistrict()); paddressBean.setDoorNo(referenceBean.getRaddressBean().getDoorNo()); paddressBean.setPincode(referenceBean.getRaddressBean().getPincode()); paddressBean.setState(referenceBean.getRaddressBean().getState()); paddressBean.setStreet(referenceBean.getRaddressBean().getStreet()); personalDetailsBean.setpAddressBean(paddressBean); session.close();/* w w w. ja v a 2 s. c om*/ if (new CommonDAO().addOrUpdateDetails(personalDetailsBean).equals("success")) { return "success"; } return null; }
From source file:biomart.DAO.RetailerDAO.java
public PersonalDetailsBean viewRetailerDetails(String userId) { Session session = Util.getSessionFactory().openSession(); PersonalDetailsBean personalDetailsBean = (PersonalDetailsBean) session.get(PersonalDetailsBean.class, userId);//from ww w . ja v a2 s.c o m session.close(); return personalDetailsBean; }
From source file:biomart.DAO.SalesmanDAO.java
public PersonalDetailsBean viewSalesmanDetails(String userId) { Session session = Util.getSessionFactory().openSession(); PersonalDetailsBean personalDetailsBean = (PersonalDetailsBean) session.get(PersonalDetailsBean.class, userId);/*from ww w .j a v a2 s . c om*/ session.close(); return personalDetailsBean; }
From source file:bookstore.dao.generic.GenericDAOImpl.java
public T findByID(Class clazz, BigDecimal id) { Session hibernateSession = this.getSession(); T t = null;/*from w w w . ja v a2 s . co m*/ t = (T) hibernateSession.get(clazz, id); return t; }
From source file:br.al.contractmanager.dao.UsuarioDao.java
@Transactional(readOnly = true) public Usuario buscar(Long id) { Session session = sessionFactory.getCurrentSession(); try {/*from w w w.j a v a2 s. co m*/ return session.get(Usuario.class, id); } catch (HibernateException e) { System.out.println(e.getMessage()); } return null; }
From source file:br.com.apprestaurante.dao.CategoriaProdutoDao.java
public CategoriaProduto getById(Integer id) { Session session = HibernateUtil.getSessionFactory().openSession(); Transaction transacao = null;//w w w . j a va2s . co m CategoriaProduto cp = null; try { transacao = session.beginTransaction(); cp = (CategoriaProduto) session.get(CategoriaProduto.class, id); transacao.commit(); return cp; } catch (HibernateException e) { if (transacao != null) { transacao.rollback(); } e.printStackTrace(); throw new HibernateException(e.getMessage()); } finally { session.close(); } }
From source file:br.com.batcommerce.dao.AdministradorDAO.java
public Administrador obter(Integer id) { Administrador administrador = null;/*w w w. j av a 2 s. c om*/ Session sessao = conexao.openSession(); administrador = (Administrador) sessao.get(Administrador.class, id); sessao.close(); return administrador; }
From source file:br.com.batcommerce.dao.ProdutoDAO.java
public Produto obter(Integer id) { Produto produto = null;/*from w w w . j ava 2 s . c o m*/ Session sessao = conexao.openSession(); produto = (Produto) sessao.get(Produto.class, id); sessao.close(); return produto; }
From source file:br.com.bean.RestControllers.alunoController.java
@RequestMapping(value = "buscaPorId-aluno", method = RequestMethod.GET) public String get(long id) throws HibernateException { Session sessao = HibernateUtility.getSession(); try {/*from w w w . j a va2s . c o m*/ Aluno a = (Aluno) sessao.get(Aluno.class, id); Gson gson = new Gson(); return gson.toJson(a, Aluno.class); } catch (HibernateException e) { return CriadorJson.criaJsonErro(e, "Verificar"); } finally { sessao.close(); } }