entities.Group_user.java Source code

Java tutorial

Introduction

Here is the source code for entities.Group_user.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: btwesigye
 * License Type: Purchased
 */
package entities;

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

import java.io.Serializable;
import javax.persistence.*;

@Entity
@org.hibernate.annotations.Proxy(lazy = false)
@Table(name = "group_user")
public class Group_user implements Serializable {
    public Group_user() {
    }

    public static Group_user loadGroup_userByORMID(int group_user_id) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return loadGroup_userByORMID(session, group_user_id);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user getGroup_userByORMID(int group_user_id) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return getGroup_userByORMID(session, group_user_id);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user loadGroup_userByORMID(int group_user_id, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return loadGroup_userByORMID(session, group_user_id, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user getGroup_userByORMID(int group_user_id, org.hibernate.LockMode lockMode)
            throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return getGroup_userByORMID(session, group_user_id, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user loadGroup_userByORMID(PersistentSession session, int group_user_id)
            throws PersistentException {
        try {
            return (Group_user) session.load(entities.Group_user.class, new Integer(group_user_id));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user getGroup_userByORMID(PersistentSession session, int group_user_id)
            throws PersistentException {
        try {
            return (Group_user) session.get(entities.Group_user.class, new Integer(group_user_id));
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user loadGroup_userByORMID(PersistentSession session, int group_user_id,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            return (Group_user) session.load(entities.Group_user.class, new Integer(group_user_id), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user getGroup_userByORMID(PersistentSession session, int group_user_id,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            return (Group_user) session.get(entities.Group_user.class, new Integer(group_user_id), lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryGroup_user(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return queryGroup_user(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

    public static Group_user[] listGroup_userByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return listGroup_userByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user[] listGroup_userByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return listGroup_userByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static List queryGroup_user(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        StringBuffer sb = new StringBuffer("From entities.Group_user as Group_user");
        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 static List queryGroup_user(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From entities.Group_user as Group_user");
        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("Group_user", lockMode);
            return query.list();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

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

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

    public static Group_user loadGroup_userByQuery(String condition, String orderBy) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return loadGroup_userByQuery(session, condition, orderBy);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user loadGroup_userByQuery(String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        try {
            PersistentSession session = entities.EVotingPersistentManager.instance().getSession();
            return loadGroup_userByQuery(session, condition, orderBy, lockMode);
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user loadGroup_userByQuery(PersistentSession session, String condition, String orderBy)
            throws PersistentException {
        Group_user[] group_users = listGroup_userByQuery(session, condition, orderBy);
        if (group_users != null && group_users.length > 0)
            return group_users[0];
        else
            return null;
    }

    public static Group_user loadGroup_userByQuery(PersistentSession session, String condition, String orderBy,
            org.hibernate.LockMode lockMode) throws PersistentException {
        Group_user[] group_users = listGroup_userByQuery(session, condition, orderBy, lockMode);
        if (group_users != null && group_users.length > 0)
            return group_users[0];
        else
            return null;
    }

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

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

    public static java.util.Iterator iterateGroup_userByQuery(PersistentSession session, String condition,
            String orderBy) throws PersistentException {
        StringBuffer sb = new StringBuffer("From entities.Group_user as Group_user");
        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 static java.util.Iterator iterateGroup_userByQuery(PersistentSession session, String condition,
            String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
        StringBuffer sb = new StringBuffer("From entities.Group_user as Group_user");
        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("Group_user", lockMode);
            return query.iterate();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public static Group_user loadGroup_userByCriteria(Group_userCriteria group_userCriteria) {
        Group_user[] group_users = listGroup_userByCriteria(group_userCriteria);
        if (group_users == null || group_users.length == 0) {
            return null;
        }
        return group_users[0];
    }

    public static Group_user[] listGroup_userByCriteria(Group_userCriteria group_userCriteria) {
        return group_userCriteria.listGroup_user();
    }

    public static Group_user createGroup_user() {
        return new entities.Group_user();
    }

    public boolean save() throws PersistentException {
        try {
            entities.EVotingPersistentManager.instance().saveObject(this);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean delete() throws PersistentException {
        try {
            entities.EVotingPersistentManager.instance().deleteObject(this);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean refresh() throws PersistentException {
        try {
            entities.EVotingPersistentManager.instance().getSession().refresh(this);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean evict() throws PersistentException {
        try {
            entities.EVotingPersistentManager.instance().getSession().evict(this);
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean deleteAndDissociate() throws PersistentException {
        try {
            if (getUser_detail() != null) {
                getUser_detail().getGroup_user().remove(this);
            }

            if (getGroup_detail() != null) {
                getGroup_detail().getGroup_user().remove(this);
            }

            return delete();
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    public boolean deleteAndDissociate(org.orm.PersistentSession session) throws PersistentException {
        try {
            if (getUser_detail() != null) {
                getUser_detail().getGroup_user().remove(this);
            }

            if (getGroup_detail() != null) {
                getGroup_detail().getGroup_user().remove(this);
            }

            try {
                session.delete(this);
                return true;
            } catch (Exception e) {
                return false;
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new PersistentException(e);
        }
    }

    @Column(name = "group_user_id", nullable = false, length = 11)
    @Id
    @GeneratedValue(generator = "ENTITIES_GROUP_USER_GROUP_USER_ID_GENERATOR")
    @org.hibernate.annotations.GenericGenerator(name = "ENTITIES_GROUP_USER_GROUP_USER_ID_GENERATOR", strategy = "native")
    private int group_user_id;

    @ManyToOne(targetEntity = entities.User_detail.class, fetch = FetchType.LAZY)
    @org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.LOCK })
    @JoinColumns({
            @JoinColumn(name = "user_detail_id", referencedColumnName = "user_detail_id", nullable = false) })
    private entities.User_detail user_detail;

    @ManyToOne(targetEntity = entities.Group_detail.class, fetch = FetchType.LAZY)
    @org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.LOCK })
    @JoinColumns({
            @JoinColumn(name = "group_detail_id", referencedColumnName = "group_detail_id", nullable = false) })
    private entities.Group_detail group_detail;

    @Column(name = "is_deleted", nullable = true, length = 1)
    private Integer is_deleted;

    @Column(name = "is_active", nullable = false, length = 1)
    private int is_active;

    @Column(name = "add_date", nullable = true)
    private java.sql.Timestamp add_date;

    @Column(name = "add_by", nullable = true, length = 11)
    private Integer add_by;

    @Column(name = "last_edit_date", nullable = true)
    private java.sql.Timestamp last_edit_date;

    @Column(name = "last_edit_by", nullable = true, length = 11)
    private Integer last_edit_by;

    private void setGroup_user_id(int value) {
        this.group_user_id = value;
    }

    public int getGroup_user_id() {
        return group_user_id;
    }

    public int getORMID() {
        return getGroup_user_id();
    }

    public void setIs_deleted(int value) {
        setIs_deleted(new Integer(value));
    }

    public void setIs_deleted(Integer value) {
        this.is_deleted = value;
    }

    public Integer getIs_deleted() {
        return is_deleted;
    }

    public void setIs_active(int value) {
        this.is_active = value;
    }

    public int getIs_active() {
        return is_active;
    }

    public void setAdd_date(java.sql.Timestamp value) {
        this.add_date = value;
    }

    public java.sql.Timestamp getAdd_date() {
        return add_date;
    }

    public void setAdd_by(int value) {
        setAdd_by(new Integer(value));
    }

    public void setAdd_by(Integer value) {
        this.add_by = value;
    }

    public Integer getAdd_by() {
        return add_by;
    }

    public void setLast_edit_date(java.sql.Timestamp value) {
        this.last_edit_date = value;
    }

    public java.sql.Timestamp getLast_edit_date() {
        return last_edit_date;
    }

    public void setLast_edit_by(int value) {
        setLast_edit_by(new Integer(value));
    }

    public void setLast_edit_by(Integer value) {
        this.last_edit_by = value;
    }

    public Integer getLast_edit_by() {
        return last_edit_by;
    }

    public void setUser_detail(entities.User_detail value) {
        this.user_detail = value;
    }

    public entities.User_detail getUser_detail() {
        return user_detail;
    }

    public void setGroup_detail(entities.Group_detail value) {
        this.group_detail = value;
    }

    public entities.Group_detail getGroup_detail() {
        return group_detail;
    }

    public String toString() {
        return String.valueOf(getGroup_user_id());
    }

}