package com.bankaudit.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;

@Embeddable
public class MaintEntityId implements Serializable {

/*	Table: maint_entity
	-----------------------

	Column Information
	----------------------

	Field              Type         Collation          Null    Key     Default              Extra   Privileges                       Comment  
	-----------------  -----------  -----------------  ------  ------  -------------------  ------  -------------------------------  ---------
	legal_entity_code  int(2)       (NULL)             NO      PRI     (NULL)                       select,insert,update,references           
	level_code         int(2)       (NULL)             NO              (NULL)                       select,insert,update,references           
	parent_unit_code   varchar(50)  latin1_swedish_ci  NO              (NULL)                       select,insert,update,references           
	unit_code          varchar(50)  latin1_swedish_ci  NO      PRI     (NULL)                       select,insert,update,references           
	unit_name          varchar(50)  latin1_swedish_ci  NO              (NULL)                       select,insert,update,references           
	status             int(2)       (NULL)             NO              (NULL)                       select,insert,update,references           
	maker              varchar(50)  latin1_swedish_ci  NO              (NULL)                       select,insert,update,references           
	maker_timestamp    timestamp    (NULL)             YES             (NULL)                       select,insert,update,references           
	checker            varchar(50)  latin1_swedish_ci  NO              (NULL)                       select,insert,update,references           
	checker_timestamp  timestamp    (NULL)             YES             (NULL)                       select,insert,update,references           
	timestamp    */
	
	    @Column(name = "unit_code")
	    private String unitCode;
	    
	    @Column(name = "legal_entity_code")
	    private Integer legalEntityCode;
	    
	    
		public MaintEntityId() {
	    }
	 
	    public MaintEntityId(Integer legalEntityCode, String unitCode) {
	        this.legalEntityCode = legalEntityCode;
	        this.unitCode = unitCode;
	    }
	 
		/**
		 * @return the legalEntityCode
		 */
		public Integer getLegalEntityCode() {
			return legalEntityCode;
		}

		public String getUnitCode() {
			return unitCode;
		}

		/* (non-Javadoc)
		 * @see java.lang.Object#hashCode()
		 */
		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + ((legalEntityCode == null) ? 0 : legalEntityCode.hashCode());
			result = prime * result + ((unitCode == null) ? 0 : unitCode.hashCode());
			return result;
		}

		/* (non-Javadoc)
		 * @see java.lang.Object#equals(java.lang.Object)
		 */
		@Override
		public boolean equals(Object obj) {
			if (this == obj) {
				return true;
			}
			if (obj == null) {
				return false;
			}
			if (!(obj instanceof MaintEntityId)) {
				return false;
			}
			MaintEntityId other = (MaintEntityId) obj;
			if (legalEntityCode == null) {
				if (other.legalEntityCode != null) {
					return false;
				}
			} else if (!legalEntityCode.equals(other.legalEntityCode)) {
				return false;
			}
			if (unitCode == null) {
				if (other.unitCode != null) {
					return false;
				}
			} else if (!unitCode.equals(other.unitCode)) {
				return false;
			}
			return true;
		}

		


 
}
