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.PaymentsManagement.java

public Payments savePayment(Employers emp, String payment, Date payedDate, Date pDate, String paymentStates,
        String paymentTypes, String paymentFor) {
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    Payments p = new Payments();
    try {/*from   w w  w .ja va  2s.c o m*/
        p.setEmployers(emp);
        p.setPayment(convertToBytes(payment));
        p.setPaymentDate(pDate);
        p.setPaymentFor(convertToBytes(paymentFor));
        p.setPaymentPayed(payedDate);
        p.setPaymentStates(convertToBytes(paymentStates));
        p.setPaymentTypes(convertToBytes(paymentTypes));
        s.save(p);
    } catch (Exception e) {
        t.rollback();
        e.printStackTrace();
    }
    t.commit();
    s.flush();
    s.close();
    return p;
}

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

public List<Payments> getAllPayments() {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(Payments.class);
    List<Payments> l = c.list();
    s.flush();
    s.close();/*  w w  w. java  2 s  . c  om*/
    return l;
}

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

public List<PaymentTypes> getAllPaymentTypes() {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(PaymentTypes.class);
    List<PaymentTypes> l = c.list();
    s.flush();
    s.close();//from   w  w  w .  j  a va2s  .  c om
    return l;
}

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

public Interfaces saveInterface(String interfaceName) {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(Interfaces.class);
    c.add(Restrictions.eq("interfaceName", convertToBytes(interfaceName)));
    Interfaces checkinterface = (Interfaces) c.uniqueResult();
    if (checkinterface == null) {
        Transaction t = s.beginTransaction();
        Interfaces i = new Interfaces();
        try {/*from   w ww . j  a v a2s .co  m*/
            i.setInterfaceName(convertToBytes(interfaceName));
            s.save(i);
        } catch (Exception e) {
            t.rollback();
            e.printStackTrace();
        }
        t.commit();
        return i;
    }
    s.flush();
    s.close();
    return checkinterface;
}

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

public InterfacesHasUserLogin saveInterfacesHasUserLogin(Interfaces interfacedb, Integer delete, Integer save,
        Integer search, Integer permissionType, Integer update, UserLogin uLogin) {
    if (loadPermission(uLogin, interfacedb)) {
        Session s = Connection.getSessionFactory().openSession();
        Transaction t = s.beginTransaction();
        InterfacesHasUserLogin hasUserLogin = new InterfacesHasUserLogin();
        try {//  ww w.jav  a 2  s  . co m
            hasUserLogin.setInterfaces(interfacedb);
            hasUserLogin.setPermissionDelete(delete);
            hasUserLogin.setPermissionSave(save);
            hasUserLogin.setPermissionSearch(search);
            hasUserLogin.setPermissionType(permissionType);
            hasUserLogin.setPermissionUpdate(update);
            hasUserLogin.setUserLogin(uLogin);
            s.save(hasUserLogin);
        } catch (Exception e) {
            t.rollback();
            e.printStackTrace();
        }
        t.commit();
        s.flush();
        s.close();
        return hasUserLogin;
    }
    return null;
}

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

public List<Interfaces> getAllInterfaces() {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(Interfaces.class);
    List<Interfaces> interfaceses = c.list();
    s.flush();
    s.close();//from www  .  ja  v a2 s. co m
    return interfaceses;
}

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

public InterfacesHasUserLogin updateInterfacesHasUserLogin(Interfaces interfacedb, Integer delete, Integer save,
        Integer search, Integer permissionType, Integer update, UserLogin uLogin, int id) {
    if (loadPermission(uLogin, interfacedb)) {
        Session s = Connection.getSessionFactory().openSession();
        Transaction t = s.beginTransaction();
        InterfacesHasUserLogin hasUserLogin = (InterfacesHasUserLogin) s.load(InterfacesHasUserLogin.class, id);
        try {//from  w  w w .ja v  a  2s .c o m
            hasUserLogin.setInterfaces(interfacedb);
            hasUserLogin.setPermissionDelete(delete);
            hasUserLogin.setPermissionSave(save);
            hasUserLogin.setPermissionSearch(search);
            hasUserLogin.setPermissionType(permissionType);
            hasUserLogin.setPermissionUpdate(update);
            hasUserLogin.setUserLogin(uLogin);
            s.update(hasUserLogin);
        } catch (Exception e) {
            t.rollback();
            e.printStackTrace();
        }
        t.commit();
        s.flush();
        s.close();
        return hasUserLogin;
    }
    return null;
}

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

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

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

public Interfaces loadInterface(String interfaceName) {
    Session s = Connection.getSessionFactory().openSession();
    Criteria c = s.createCriteria(Interfaces.class);
    c.add(Restrictions.eq("interfaceName", convertToBytes(interfaceName)));
    Interfaces i = (Interfaces) c.uniqueResult();
    s.flush();
    s.close();/*from w  w  w . j av  a2  s.co  m*/
    return i;
}

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

public Clients saveClients(String address, String cantactPersonDepartment, String contactNo,
        String contactPerson, String contactPersonDesignation, String contactPersonEmail,
        String contactPersonNo, String email, String name) {
    Session s = Connection.getSessionFactory().openSession();
    Transaction t = s.beginTransaction();
    Clients c = new Clients();
    try {/*from   w  w  w .j  av a 2 s.  c o  m*/
        c.setAddress(convertToBytes(address));
        c.setCantactPersonDepartment(convertToBytes(cantactPersonDepartment));
        c.setContactNo(convertToBytes(contactNo));
        c.setContactPerson(convertToBytes(contactPerson));
        c.setContactPersonDesignation(convertToBytes(contactPersonDesignation));
        c.setContactPersonEmail(convertToBytes(contactPersonEmail));
        c.setContactPersonNo(convertToBytes(contactPersonNo));
        c.setEmail(convertToBytes(email));
        c.setName(convertToBytes(name));
        s.save(c);
    } catch (Exception e) {
        t.rollback();
        e.printStackTrace();
    }
    t.commit();
    s.flush();
    s.close();
    return c;
}