Package org.hibernate

Examples of org.hibernate.Session.beginTransaction()


    Object[][] data;

    public CustomerListTableModel(String hql) {
        super();
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();
        Vector<Object[]> customers = new Vector<Object[]>();
        for (Object cus : sess.createQuery("from Customer" + hql).list()) {
            Customer c = (Customer) cus;
            customers.add(new Object[] {
                c.getId(),
View Full Code Here


                emp.getTimeClockEvents().add(0, evt);
                emp.setIsClockedIn(true);
                user.setEmployee(emp);
                org.hibernate.Transaction tx = null;
                try {
                    tx = sess.beginTransaction();
                    sess.save(evt);
                    sess.update(emp);
                    sess.update(user);
                    tx.commit();
                } catch (HibernateException he) {
View Full Code Here

                emp.getTimeClockEvents().add(0, evt);
                emp.setIsClockedIn(false);
                user.setEmployee(emp);
                org.hibernate.Transaction tx = null;
                try {
                    tx = sess.beginTransaction();
                    sess.save(evt);
                    sess.update(emp);
                    sess.update(user);
                    tx.commit();
                } catch (HibernateException he) {
View Full Code Here

    Object[][] data;
   
    public EmployeeListTableModel(String hql) {
        super();
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();
        Vector<Object[]> employees = new Vector<Object[]>();
        for (Object emp : sess.createQuery("from Employee" + hql).list()) {
            Employee e = (Employee) emp;
            employees.add(new Object[] {
                e.getId(),
View Full Code Here

        ResourceBundle rb = ResourceBundle.getBundle(
                "FieldTitles", Locale.getDefault());

        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        // Create a new Employee and associated user and address
        User u = new User();
        Address a = new Address();
        Employee emp = new Employee();
View Full Code Here

        if (!UserContainer.getUser().hasPermission("change_employee")) {
            throw new PermissionDeniedException();
        }

        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        // Get the employee and associated user
        Employee emp = (Employee) sess.load(Employee.class, id);
        User u = emp.getUser();
View Full Code Here

        return emp;
    }

    public static void deleteEmployee(int id) {
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        Employee emp = (Employee) sess.load(Employee.class, id);
        sess.delete(emp);

        sess.getTransaction().commit();
View Full Code Here

     * @param password The plain-text password
     * @return True if the login was successful, false otherwise
     */
    public boolean doLogin(String username, String password) {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        user = (User) session.createQuery("from User where username = ?").setString(0, username).uniqueResult();
        try {
            if (user.authenticate(password)) {
                //session.getTransaction().commit();
                return true;
View Full Code Here

            return false;
        }

        // Otherwise, really go out and check our permissions.
        Session sess = HibernateUtil.getSessionFactory().getCurrentSession();
        sess.beginTransaction();

        // Use a current instance of our user
        User u = (User) sess.load(User.class, getId());

        // Check user permissions
View Full Code Here

      @Override
      public String call() throws Exception {
        Session session = openSession();

        Transaction transaction = session.beginTransaction();
        final Novel novel = (Novel) session.get( Novel.class, "novel-1" );
        novel.setDescription( "Description 2" );
        transaction.commit();

        return novel.get_rev();
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.