Example usage for org.hibernate Session load

List of usage examples for org.hibernate Session load

Introduction

In this page you can find the example usage for org.hibernate Session load.

Prototype

void load(Object object, Serializable id);

Source Link

Document

Read the persistent state associated with the given identifier into the given transient instance.

Usage

From source file:com.actop.model.ProjectsManagement.java

public ProjectTaskStates loadProjectStatus(int pid) {
    Session s = Connection.getSessionFactory().openSession();
    ProjectTaskStates pts = (ProjectTaskStates) s.load(ProjectTaskStates.class, pid);
    s.flush();//from  ww  w. j  a  v  a 2 s  . co m
    s.close();
    return pts;
}

From source file:com.actop.model.PromotionManagement.java

public Promotions promoteEmployer(int pid, String promotBy, Date approvedDate, String promotionApprovedBy,
        Date effectiveDate, String promotionStates) {
    Session s = Connection.getSessionFactory().openSession();
    Promotions p = (Promotions) s.load(Promotions.class, pid);
    Transaction t = s.beginTransaction();
    try {//from   ww  w .  j a v  a2 s.c  o  m
        Criteria c = s.createCriteria(DepartmentsHasDesignation.class);
        c.add(Restrictions.eq("employers", p.getEmployers()));
        DepartmentsHasDesignation dhd = (DepartmentsHasDesignation) c.uniqueResult();
        Criteria c1 = s.createCriteria(Designation.class);
        c1.add(Restrictions.eq("designation", p.getPromotionFor()));
        Designation d = (Designation) c.uniqueResult();
        dhd.setDesignation(d);
        s.update(dhd);
        p.setPromotBy(convertToBytes(promotBy));
        //            p.setPromotionApproved(approvedDate);
        //            p.setPromotionApprovedBy(convertToBytes(promotionApprovedBy));
        p.setPromotionEffectiveDate(effectiveDate);
        p.setPromotionStates(convertToBytes(promotionStates));
        s.update(p);
    } catch (Exception e) {
        t.rollback();
    }
    t.commit();
    s.flush();
    s.close();
    return p;
}

From source file:com.actop.model.PromotionManagement.java

public Promotions getPromotion(int id) {
    Session s = Connection.getSessionFactory().openSession();
    Promotions p = (Promotions) s.load(Promotions.class, id);
    s.flush();//from ww  w  . j  a  v  a2  s  . c om
    s.close();
    return p;
}

From source file:com.actop.model.UserManagement.java

public Employers updateEmployers(int empID, String sFullName, String sCallingName, String address1,
        String address2, Date appointedDate, String appointedType, String bloodGroup, String branch,
        String callingName, String city, String district, String epf, String extensionNo, String homeNo,
        String imgPath, String licenseNo, String mobileNo, String nic, String officeEmail, String officeNo,
        String passport, String paymetsBank, String paymetsBankAccountNumber, String paymetsBankBranch,
        String paymetsBankPersonName, String personalEmail, String reportBy, Date resigningDate,
        String salary) {/*from ww w  .java 2 s.c o m*/
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    Employers e = (Employers) s.load(Employers.class, empID);
    try {

        e.setAddress1(convertToBytes(address1));
        e.setAddress2(convertToBytes(address2));
        e.setAppointedDate(appointedDate);
        e.setAppointedType(convertToBytes(appointedType));
        e.setBloodGroup(convertToBytes(bloodGroup));
        e.setBranch(convertToBytes(branch));
        e.setCallingName(convertToBytes(callingName));
        e.setCity(convertToBytes(city));
        e.setDistrict(convertToBytes(district));
        e.setEpf(convertToBytes(epf));
        e.setExtensionNo(convertToBytes(extensionNo));
        e.setFullName(convertToBytes(sFullName));
        e.setHomeNo(convertToBytes(homeNo));

        e.setLicenseNo(convertToBytes(licenseNo));
        e.setMobileNo(convertToBytes(mobileNo));
        e.setNic(convertToBytes(nic));
        e.setOfficeEmail(convertToBytes(officeEmail));
        e.setOfficeNo(convertToBytes(officeNo));
        e.setPassport(convertToBytes(passport));
        e.setPaymetsBank(convertToBytes(paymetsBank));
        e.setPaymetsBankAccountNumber(convertToBytes(paymetsBankAccountNumber));
        e.setPaymetsBankBranch(convertToBytes(paymetsBankBranch));
        e.setPaymetsBankPersonName(convertToBytes(paymetsBankPersonName));
        e.setPersonalEmail(convertToBytes(personalEmail));
        e.setReportBy(convertToBytes(reportBy));
        e.setResigningDate(resigningDate);
        e.setSalary(convertToBytes(salary));
        e.setStatus(1);
        s.save(e);

    } catch (Exception ex) {
        t.rollback();
        ex.printStackTrace();
    }
    t.commit();
    s.flush();
    s.close();
    return e;
}

From source file:com.actop.model.UserManagement.java

public UserLogin updateUserLogin(String answer1, String answer2, Employers employer, String pw,
        String securityq1, String securityq2, String un, int ulid) {
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    UserLogin ul = (UserLogin) s.load(UserLogin.class, ulid);
    try {/*w w  w.  ja va  2 s.co  m*/
        ul.setAnswer1(convertToBytes(answer1));
        ul.setAnswer2(convertToBytes(answer2));
        ul.setEmployers(employer);
        ul.setPw(convertToBytes(pw));
        ul.setSecurityq1(convertToBytes(securityq1));
        ul.setSecurityq2(convertToBytes(securityq2));
        ul.setUn(convertToBytes(un));
        s.save(ul);
    } catch (Exception e) {
        t.rollback();
        e.printStackTrace();
    }
    t.commit();
    s.flush();
    s.close();
    return ul;
}

From source file:com.actop.model.UserManagement.java

public Departments loadDepartment(int id) {
    Session s = Connection.getSessionFactory().openSession();
    Departments d = (Departments) s.load(Departments.class, id);
    s.flush();//  w  ww  .j a v  a2  s  .c  o  m
    s.close();
    return d;
}

From source file:com.actop.model.UserManagement.java

public Allowances loadAllowance(int id) {
    Session s = Connection.getSessionFactory().openSession();
    Allowances a = (Allowances) s.load(Allowances.class, id);
    s.flush();/*from ww w  . ja v a  2  s.c o  m*/
    s.close();
    return a;
}

From source file:com.actop.model.UserManagement.java

public Designation loadDesignation(int id) {
    Session s = Connection.getSessionFactory().openSession();
    Designation d = (Designation) s.load(Designation.class, id);
    s.flush();/*from w ww. j  a v  a2s . c  o  m*/
    s.close();
    return d;
}

From source file:com.actop.model.UserManagement.java

public DepartmentsHasDesignation loadDepartmentsHasDesignation(int id) {
    Session s = Connection.getSessionFactory().openSession();
    DepartmentsHasDesignation dhd = (DepartmentsHasDesignation) s.load(DepartmentsHasDesignation.class, id);
    s.flush();//  w  w  w . j a v a  2 s  .co  m
    s.close();
    return dhd;
}

From source file:com.adsapient.shared.dao.HibernateEntityDao.java

License:Open Source License

public Object loadObject(final Class objClass, final String ObjectId) {
    return getHibernateTemplate().execute(new HibernateCallback() {
        public Object doInHibernate(Session session) throws HibernateException {
            session.setCacheMode(CacheMode.IGNORE);
            return session.load(objClass, ObjectId);
        }/*from ww w .  j  ava2s.  co  m*/
    });
}