Example usage for org.hibernate Session flush

List of usage examples for org.hibernate Session flush

Introduction

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

Prototype

void flush() throws HibernateException;

Source Link

Document

Force this session to flush.

Usage

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

public List<ProjectTypes> getAllProjectTypes() {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(ProjectTypes.class);
    List<ProjectTypes> l = c.list();
    s.flush();
    s.close();/*from  ww  w.ja v  a 2 s.c o  m*/
    return l;
}

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

public Promotions savePromotion(String beforepromotion, Employers emp, String promotBy, Date applyDate,
        Date approvedate, String promotionApprovedBy, Date promoeffectiveDate, String promotionFor,
        String promotionStates) {
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    Promotions p = new Promotions();
    try {/*  w w w.  j  a  v a 2 s . c  om*/
        System.out.println("awasave");
        p.setBeforePromotion(convertToBytes(beforepromotion));
        p.setEmployers(emp);
        p.setPromotBy(convertToBytes(promotBy));
        p.setPromotionApplyDate(applyDate);
        //            p.setPromotionApproved(approvedate);
        //            p.setPromotionApprovedBy(convertToBytes(promotionApprovedBy));
        p.setPromotionEffectiveDate(promoeffectiveDate);
        p.setPromotionFor(convertToBytes(promotionFor));
        p.setPromotionStates(convertToBytes(promotionStates));
        s.save(p);

        System.out.println("awasave2");
    } catch (Exception e) {
        t.rollback();
        e.printStackTrace();
    }
    t.commit();
    s.flush();
    s.close();
    return p;
}

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

public List<Promotions> getallPromotions() {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(Promotions.class);
    List<Promotions> promotionses = c.list();
    s.flush();
    s.close();//from   w  w w . ja v a  2  s  .c  o m
    return promotionses;
}

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 {/* ww w .j av  a 2 s . co 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();
    s.close();//from w w w  . j a  va2s . c o  m
    return p;
}

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

public Employers saveEmployers(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) {/*w  w w .ja  v  a 2 s. com*/
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    Employers e = new Employers();
    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.setImgPath(convertToBytes(imgPath));
        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 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 .  j  a va2s. com
    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 saveUserLogin(String answer1, String answer2, Employers employer, String pw, String securityq1,
        String securityq2, String un) {
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    UserLogin ul = new UserLogin();
    try {//from   www. ja  v  a2  s . com
        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 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 {/*from w  w  w .  ja v a  2s .  com*/
        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 boolean checkUser(String un) {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(UserLogin.class);
    c.add(Restrictions.eq("un", convertToBytes(un)));
    UserLogin ul = (UserLogin) c.uniqueResult();
    s.flush();
    s.close();/*from  w ww. j  a  va 2  s .  c o  m*/
    if (ul != null) {
        return false;
    } else {
        return true;
    }
}