/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.qsoft.rs.sincoar.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author developer2
 */
@Entity
@Table(name="COMACO.TGENEMENUSUBLEVEL")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tgenemenusublevel.findAll", query = "SELECT t FROM Tgenemenusublevel t"),
    @NamedQuery(name = "Tgenemenusublevel.findByMenucode", query = "SELECT t FROM Tgenemenusublevel t WHERE t.tgenemenusublevelPK.menucode = :menucode"),
    @NamedQuery(name = "Tgenemenusublevel.findByLevelcode", query = "SELECT t FROM Tgenemenusublevel t WHERE t.tgenemenusublevelPK.levelcode = :levelcode"),
    @NamedQuery(name = "Tgenemenusublevel.findBySublevel", query = "SELECT t FROM Tgenemenusublevel t WHERE t.tgenemenusublevelPK.sublevel = :sublevel"),
    @NamedQuery(name = "Tgenemenusublevel.findByPresentationorder", query = "SELECT t FROM Tgenemenusublevel t WHERE t.presentationorder = :presentationorder")})
public class Tgenemenusublevel implements Serializable {

    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TgenemenusublevelPK tgenemenusublevelPK;
    @Column(name = "PRESENTATIONORDER")
    private Short presentationorder;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenemenusublevel")
    private Collection<Tgenemenusubleveldesc> tgenemenusubleveldescCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tgenemenusublevel")
    private Collection<Tgenemenusubleveltran> tgenemenusubleveltranCollection;
    @JoinColumns({
        @JoinColumn(name = "MENUCODE", referencedColumnName = "MENUCODE", insertable = false, updatable = false),
        @JoinColumn(name = "LEVELCODE", referencedColumnName = "LEVELCODE", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Tgenemenulevel tgenemenulevel;

    public Tgenemenusublevel() {
    }

    public Tgenemenusublevel(TgenemenusublevelPK tgenemenusublevelPK) {
        this.tgenemenusublevelPK = tgenemenusublevelPK;
    }

    public Tgenemenusublevel(int menucode, int levelcode, int sublevel) {
        this.tgenemenusublevelPK = new TgenemenusublevelPK(menucode, levelcode, sublevel);
    }

    public TgenemenusublevelPK getTgenemenusublevelPK() {
        return tgenemenusublevelPK;
    }

    public void setTgenemenusublevelPK(TgenemenusublevelPK tgenemenusublevelPK) {
        this.tgenemenusublevelPK = tgenemenusublevelPK;
    }

    public Short getPresentationorder() {
        return presentationorder;
    }

    public void setPresentationorder(Short presentationorder) {
        this.presentationorder = presentationorder;
    }

    @XmlTransient
    public Collection<Tgenemenusubleveldesc> getTgenemenusubleveldescCollection() {
        return tgenemenusubleveldescCollection;
    }

    public void setTgenemenusubleveldescCollection(Collection<Tgenemenusubleveldesc> tgenemenusubleveldescCollection) {
        this.tgenemenusubleveldescCollection = tgenemenusubleveldescCollection;
    }

    @XmlTransient
    public Collection<Tgenemenusubleveltran> getTgenemenusubleveltranCollection() {
        return tgenemenusubleveltranCollection;
    }

    public void setTgenemenusubleveltranCollection(Collection<Tgenemenusubleveltran> tgenemenusubleveltranCollection) {
        this.tgenemenusubleveltranCollection = tgenemenusubleveltranCollection;
    }

    public Tgenemenulevel getTgenemenulevel() {
        return tgenemenulevel;
    }

    public void setTgenemenulevel(Tgenemenulevel tgenemenulevel) {
        this.tgenemenulevel = tgenemenulevel;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (tgenemenusublevelPK != null ? tgenemenusublevelPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tgenemenusublevel)) {
            return false;
        }
        Tgenemenusublevel other = (Tgenemenusublevel) object;
        if ((this.tgenemenusublevelPK == null && other.tgenemenusublevelPK != null) || (this.tgenemenusublevelPK != null && !this.tgenemenusublevelPK.equals(other.tgenemenusublevelPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsoft.rs.sincoar.model.Tgenemenusublevel[ tgenemenusublevelPK=" + tgenemenusublevelPK + " ]";
    }
    
}
