Package org.hibernate

Examples of org.hibernate.Session.load()


    s = openSession();
    tx = s.beginTransaction();
    emp = (Employer) s.load( "org.hibernate.ejb.test.ops.Employer", emp.getId() );
    emp.getId();
    assertFalse( Hibernate.isInitialized( emp ) );
    node = (Node) s.load( "org.hibernate.ejb.test.ops.Node", node.getName() );
    assertEquals( node.getName(), "foo" );
    assertFalse( Hibernate.isInitialized( node ) );
    tx.commit();
    s.close();
View Full Code Here


  protected T load(Id id) throws Exception {
    Object obj = null;
    Session session = null;
    try {
      session = getSession();
      obj = session.load(domainClass, id);
    } catch (HibernateException e) {
      handleException(e);
    } finally {
      closeSession();
    }
View Full Code Here

  protected T load(Id id) throws Exception {
    Object obj = null;
    Session session = null;
    try {
      session = getSession();
      obj = session.load(domainClass, id);
    } catch (HibernateException e) {
      handleException(e);
    }
    return (T) obj;
  }
View Full Code Here

        StudentAudited student;

        try {
            Session session = sessionFactory.openSession();
            Transaction trans = session.beginTransaction();
            student = (StudentAudited) session.load(StudentAudited.class, id);
            student.setAddress(address);
            session.save(student);
            session.flush();
            trans.commit();
            session.close();
View Full Code Here

        System.out.println("getStudent: started");
        Student student;

        try {
            Session session = sessionFactory.openSession();
            student = (Student) session.load(Student.class, id);
            session.close();

        } catch (Exception e) {

            e.printStackTrace();
View Full Code Here

    // update student
    public Student updateStudent(String address, int id) {

        Session session = sessionFactory.openSession();
        Student student = (Student) session.load(Student.class, id);
        student.setAddress(address);

        try {
            // invoking the Hibernate transaction
            Transaction trans = session.beginTransaction();
View Full Code Here

  @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
  protected T load(Id id) throws Exception {
    Object obj = null;
    try {
      Session session = getSession();
      obj = session.load(domainClass, id);
    } catch (HibernateException e) {
      handleException(e);
    }
    return (T) obj;
  }
View Full Code Here

      Session session = Helper.getHibernateSession();
      // first load the object with the current session.
      // the object must be loaded in this session before it
      // is deleted.
      synchronized (c) {
        Object obj = session.load(c, id);
        session.delete(obj);
        session.flush();
        session.beginTransaction().commit();
      }
    } catch (Exception e) {
View Full Code Here

  protected Object loadObj(Class c, Integer id) throws DAOException {
    try {
      Session session = Helper.getHibernateSession();
      if (session == null) {
        session = HibernateUtil.getSessionFactory().openSession();
        Object o = session.load(c, id);
        session.close();
        return o;
      }
      return session.load(c, id);
    } catch (HibernateException he) {
View Full Code Here

        session = HibernateUtil.getSessionFactory().openSession();
        Object o = session.load(c, id);
        session.close();
        return o;
      }
      return session.load(c, id);
    } catch (HibernateException he) {
      throw new DAOException(he);
    }
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.