eventapp.impl.RegularUserDAOImpl.java Source code

Java tutorial

Introduction

Here is the source code for eventapp.impl.RegularUserDAOImpl.java

Source

/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: Universidade do Minho
 * License Type: Academic
 */
package eventapp.impl;

import org.orm.*;
import org.hibernate.Query;
import org.hibernate.LockMode;
import java.util.List;
import eventapp.*;

public class RegularUserDAOImpl implements eventapp.dao.RegularUserDAO {
    public RegularUser loadRegularUserByORMID(int ID) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return loadRegularUserByORMID(session, ID);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser getRegularUserByORMID(int ID) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return getRegularUserByORMID(session, ID);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser loadRegularUserByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return loadRegularUserByORMID(session, ID, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser getRegularUserByORMID(int ID, org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return getRegularUserByORMID(session, ID, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser loadRegularUserByORMID(PersistentSession session, int ID) throws PersistentException {
        try {
            return (RegularUser) session.load(eventapp.RegularUser.class, new Integer(ID));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser getRegularUserByORMID(PersistentSession session, int ID) throws PersistentException {
        try {
            return (RegularUser) session.get(eventapp.RegularUser.class, new Integer(ID));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser loadRegularUserByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (RegularUser) session.load(eventapp.RegularUser.class, new Integer(ID), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser getRegularUserByORMID(PersistentSession session, int ID, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            return (RegularUser) session.get(eventapp.RegularUser.class, new Integer(ID), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public List queryRegularUser(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return queryRegularUser(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public List queryRegularUser(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return queryRegularUser(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser[] listRegularUserByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return listRegularUserByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser[] listRegularUserByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return listRegularUserByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public List queryRegularUser(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        StringBuffer sb = new StringBuffer("From eventapp.RegularUser as RegularUser");
        if (condition != null)
            sb.append(" Where ").append(condition);
        if (orderBy != null)
            sb.append(" Order By ").append(orderBy);
        try {
            Query query = session.createQuery(sb.toString());
            return query.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public List queryRegularUser(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From eventapp.RegularUser as RegularUser");
        if (condition != null)
            sb.append(" Where ").append(condition);
        if (orderBy != null)
            sb.append(" Order By ").append(orderBy);
        try {
            Query query = session.createQuery(sb.toString());
            query.setLockMode("RegularUser", lockMode);
            return query.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser[] listRegularUserByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        try {
            List list = queryRegularUser(session, condition, orderBy);
            return (RegularUser[]) list.toArray(new RegularUser[list.size()]);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser[] listRegularUserByQuery(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            List list = queryRegularUser(session, condition, orderBy, lockMode);
            return (RegularUser[]) list.toArray(new RegularUser[list.size()]);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser loadRegularUserByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return loadRegularUserByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser loadRegularUserByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return loadRegularUserByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser loadRegularUserByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        RegularUser[] regularUsers = listRegularUserByQuery(session, condition, orderBy);
        if (regularUsers != null && regularUsers.length > 0)
            return regularUsers[0];
        else
            return null;
    }

    public RegularUser loadRegularUserByQuery(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        RegularUser[] regularUsers = listRegularUserByQuery(session, condition, orderBy, lockMode);
        if (regularUsers != null && regularUsers.length > 0)
            return regularUsers[0];
        else
            return null;
    }

    public java.util.Iterator iterateRegularUserByQuery(String condition, String orderBy)
            throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return iterateRegularUserByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public java.util.Iterator iterateRegularUserByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = eventapp.ArchitecturePersistentManager.instance().getSession();
            return iterateRegularUserByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public java.util.Iterator iterateRegularUserByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        StringBuffer sb = new StringBuffer("From eventapp.RegularUser as RegularUser");
        if (condition != null)
            sb.append(" Where ").append(condition);
        if (orderBy != null)
            sb.append(" Order By ").append(orderBy);
        try {
            Query query = session.createQuery(sb.toString());
            return query.iterate();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public java.util.Iterator iterateRegularUserByQuery(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From eventapp.RegularUser as RegularUser");
        if (condition != null)
            sb.append(" Where ").append(condition);
        if (orderBy != null)
            sb.append(" Order By ").append(orderBy);
        try {
            Query query = session.createQuery(sb.toString());
            query.setLockMode("RegularUser", lockMode);
            return query.iterate();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public RegularUser createRegularUser() {
        return new eventapp.RegularUser();
    }

    public boolean save(eventapp.RegularUser regularUser) throws PersistentException {
        try {
            eventapp.ArchitecturePersistentManager.instance().saveObject(regularUser);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean delete(eventapp.RegularUser regularUser) throws PersistentException {
        try {
            eventapp.ArchitecturePersistentManager.instance().deleteObject(regularUser);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean deleteAndDissociate(eventapp.RegularUser regularUser) throws PersistentException {
        try {
            eventapp.Event[] lEventss = regularUser.events.toArray();
            for (int i = 0; i < lEventss.length; i++) {
                lEventss[i].regularUsers.remove(regularUser);
            }
            return delete(regularUser);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean deleteAndDissociate(eventapp.RegularUser regularUser, org.orm.PersistentSession session)
            throws PersistentException {
        try {
            eventapp.Event[] lEventss = regularUser.events.toArray();
            for (int i = 0; i < lEventss.length; i++) {
                lEventss[i].regularUsers.remove(regularUser);
            }
            try {
                session.delete(regularUser);
                return true;
            } catch (Exception e) {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean refresh(eventapp.RegularUser regularUser) throws PersistentException {
        try {
            eventapp.ArchitecturePersistentManager.instance().getSession().refresh(regularUser);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean evict(eventapp.RegularUser regularUser) throws PersistentException {
        try {
            eventapp.ArchitecturePersistentManager.instance().getSession().evict(regularUser);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

}