package net.htn.tool.domain.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import net.htn.tool.domain.dic.DataType;

@Entity
@Table(name="table_field")
public class TableField implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="id")
	private Long id;

	@Column(name="field_name", nullable = false, length=200)
	private String fieldName;

	@Column(name="field_label", nullable = false, length=200)
	private String fieldLabel;

	@ManyToOne(optional=false, fetch = FetchType.LAZY)
	@JoinColumn(name = "table_name", referencedColumnName = "table_name", nullable = false)
	private Tables refTable;

	@Column(name="data_type", nullable = false)
	@Enumerated(EnumType.STRING)
	private DataType dataType;

	@Column(name="ref_dic", nullable = true)
	private String refDic;

	@Column(name="ref_table_name", nullable = true)
	private String refTableName;

	@Column(name="ref_field_name", nullable = true)
	private String refFieldName;

	@Column(name="nullable", nullable = false)
	private Boolean nullable;

	@Column(name="length", nullable = false)
	private Integer length;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getFieldName() {
		return fieldName;
	}

	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	public String getFieldLabel() {
		return fieldLabel;
	}

	public void setFieldLabel(String fieldLabel) {
		this.fieldLabel = fieldLabel;
	}

	public Tables getRefTable() {
		return refTable;
	}

	public void setRefTable(Tables refTable) {
		this.refTable = refTable;
	}

	public DataType getDataType() {
		return dataType;
	}

	public void setDataType(DataType dataType) {
		this.dataType = dataType;
	}

	public String getRefDic() {
		return refDic;
	}

	public void setRefDic(String refDic) {
		this.refDic = refDic;
	}

	public String getRefTableName() {
		return refTableName;
	}

	public void setRefTableName(String refTableName) {
		this.refTableName = refTableName;
	}

	public String getRefFieldName() {
		return refFieldName;
	}

	public void setRefFieldName(String refFieldName) {
		this.refFieldName = refFieldName;
	}

	public Boolean getNullable() {
		return nullable;
	}

	public void setNullable(Boolean nullable) {
		this.nullable = nullable;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}
	
	
}
