package com.casic.PgInterface.devTable.domain;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;

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

/**
 * Created by yxw on 2017/10/31.
 */
@Entity
@Table(name = "PG_PIPE_GALLERY")
@SequenceGenerator(name = "SEQ_PG_PIPE_GALLERY_ID", sequenceName = "SEQ_PG_PIPE_GALLERY_ID", allocationSize = 1, initialValue = 1)
public class PipeGallery implements Serializable {

    private static final long serialVersionUID = 1L;
    private long id;
    private String pgName;//管廊名称
    private double pgLength;//仓体长度
    private int active;//状态位
    private PgPartition pgPartitionId;//
    private List<PgPipeLine> pgPipeLineList;

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_PIPE_GALLERY_ID")
    public long getId() {
        return id;
    }

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

    @Column(name = "PG_NAME")
    public String getPgName() {
        return pgName;
    }

    public void setPgName(String pgName) {
        this.pgName = pgName;
    }

    @Column(name = "PAR_LENGTH")
    public double getPgLength() {
        return pgLength;
    }

    public void setPgLength(double pgLength) {
        this.pgLength = pgLength;
    }

    @Column(name = "ACTIVE")
    public int getActive() {
        return active;
    }

    public void setActive(int active) {
        this.active = active;
    }

    @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST})
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "PARTITIONID")
    public PgPartition getPgPartitionId() {
        return pgPartitionId;
    }

    public void setPgPartitionId(PgPartition pgPartitionId) {
        this.pgPartitionId = pgPartitionId;
    }

    @OneToMany(fetch = FetchType.LAZY, mappedBy = "pipeGalleryId")
    public List<PgPipeLine> getPgPipeLineList() {
        return pgPipeLineList;
    }

    public void setPgPipeLineList(List<PgPipeLine> pgPipeLineList) {
        this.pgPipeLineList = pgPipeLineList;
    }

}
