Example usage for org.hibernate Session persist

List of usage examples for org.hibernate Session persist

Introduction

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

Prototype

void persist(Object object);

Source Link

Document

Make a transient instance persistent.

Usage

From source file:com.laborun.dao.AssignmentDaoImp.java

public void uploadAssignment(AssignmentFiles assignmentFiles) {
    Session session = Connection.getConnection();
    session.beginTransaction();/*  w  w w  . ja  v  a  2  s  .c o  m*/
    session.persist(assignmentFiles);
    session.getTransaction().commit();
    System.out.println("data inserted");
}

From source file:com.laborun.dao.CourseDaoImp.java

public boolean insertCourse(Course course) {
    boolean flag = true;
    Session session = Connection.getConnection();
    Criteria cr = session.createCriteria(Course.class);
    cr.add(Restrictions.eq("courseName", course.getCourseName()));
    List results = cr.list();// ww w .jav a2 s  .c om
    Iterator it = results.iterator();
    while (it.hasNext()) {

        flag = false;
        System.out.println("course already exists");
        break;

    }
    if (flag == true) {
        session.beginTransaction();
        session.persist(course);
        session.getTransaction().commit();
        System.out.println("data inserted");
    }
    return flag;
}

From source file:com.laborun.dao.DepartmentDaoImp.java

public boolean insertDepartment(Department department) {
    boolean flag = true;
    Session session = Connection.getConnection();
    Criteria cr = session.createCriteria(Department.class);
    cr.add(Restrictions.eq("departmentName", department.getDepartmentName()));
    List results = cr.list();//  w  w w.  j  a  v  a2  s  .c  om
    Iterator it = results.iterator();
    while (it.hasNext()) {

        flag = false;
        System.out.println("department already exists");
        break;

    }
    if (flag == true) {
        session.beginTransaction();
        session.persist(department);
        session.getTransaction().commit();
        System.out.println("data inserted");
    }
    return flag;

}

From source file:com.laborun.dao.GroupDaoImp.java

public boolean insertGroup(GroupD group) {

    boolean flag = true;
    Session session = Connection.getConnection();
    Criteria cr = session.createCriteria(GroupD.class);
    cr.add(Restrictions.eq("groupName", group.getGroupName()));
    List results = cr.list();/*from   ww  w .ja  v a2s .  c  om*/
    Iterator it = results.iterator();
    while (it.hasNext()) {

        flag = false;
        System.out.println("group already exists");
        break;

    }
    if (flag == true) {
        session.beginTransaction();
        session.persist(group);
        session.getTransaction().commit();
        System.out.println("data inserted");
    }
    return flag;

}

From source file:com.laborun.dao.IntakeDaoImp.java

public boolean insertIntake(Intake intake) {
    boolean flag = true;
    Session session = Connection.getConnection();
    Criteria cr = session.createCriteria(Intake.class);
    cr.add(Restrictions.eq("intakeNum", intake.getIntakeNum()));
    List results = cr.list();/*from  w w w  .  j a  v a  2  s  . co  m*/
    Iterator it = results.iterator();
    while (it.hasNext()) {

        flag = false;
        System.out.println("intake already exists");
        break;

    }
    if (flag == true) {
        session.beginTransaction();
        session.persist(intake);
        session.getTransaction().commit();
        System.out.println("data inserted");
    }
    return flag;
}

From source file:com.laborun.dao.LabDaoImp.java

public void insertLab(Lab lab) {

    Session session = Connection.getConnection();
    session.beginTransaction();//from  www  . ja v a 2  s. com
    session.persist(lab);
    session.getTransaction().commit();
    System.out.println("data inserted");
}

From source file:com.laborun.dao.QueueDaoImp.java

@Override
public void setTraineeInQueue(QueueD queue, Set<TraineeInQueue> traineesInQueue) {
    Session session = Connection.getConnection();
    session.beginTransaction();//from   w  w  w  . ja v  a 2s.c o  m

    for (TraineeInQueue traineeInQueue : traineesInQueue) {
        TraineeInQueue traineeCopy = new TraineeInQueue();

        traineeCopy.setId(new TraineeInQueueId(traineeInQueue.getTrainee().getId(), queue.getId()));
        traineeCopy.setTrainee(traineeInQueue.getTrainee());
        traineeCopy.setQueueD(queue);
        traineeCopy.setOrderNum(traineeInQueue.getOrderNum());

        session.persist(traineeCopy);
    }

    session.getTransaction().commit();
}

From source file:com.laborun.dao.QueueDaoImp.java

public void addNewRequest(QueueD queue) {
    Session session = Connection.getConnection();
    session.beginTransaction();/*  w  w  w .ja  v  a  2 s .  c o m*/
    session.persist(queue);
    session.getTransaction().commit();
    System.out.println("data inserted");
}

From source file:com.laborun.dao.RequestQueueImp.java

public void insertTraineeInQueue(Trainee trainee, QueueD queue) {
    Session session = Connection.getConnection();
    TraineeInQueue t = new TraineeInQueue();
    t.setId(new TraineeInQueueId(trainee.getId(), queue.getId()));
    session.beginTransaction();//from  w  w w.ja  va2  s.  c o  m
    session.persist(t);
    session.getTransaction().commit();
    System.out.println("data inserted");

}

From source file:com.laborun.dao.StaffDaoImp.java

public void insertStaffData(Staff staff) {
    staff.setRole("staff");
    Session session = Connection.getConnection();
    session.beginTransaction();/*from   w  w  w  .j a  v a  2s  . co  m*/
    session.persist(staff);
    session.getTransaction().commit();
    System.out.println("data inserted");
}