package com.casic.PgInterface.patroler.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 2018/3/19. */ @Entity @Table(name = "PG_ROLE") @SequenceGenerator(name = "SEQ_PG_ROLE_ID", sequenceName = "SEQ_PG_ROLE_ID",allocationSize=1,initialValue=1) public class PgRole implements Serializable { private static final long serialVersionUID = 1L; private long id; private String role; private int active; private PgAuthority pgAuthorityId; private List<PgUser> pgUsers; @Id @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_PG_ROLE_ID") public long getId() { return id; } public void setId(long id) { this.id = id; } @Column(name = "ROLE") public String getRole() { return role; } public void setRole(String role) { this.role = role; } @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 = "AUTHORITYID") public PgAuthority getPgAuthorityId() { return pgAuthorityId; } public void setPgAuthorityId(PgAuthority pgAuthorityId) { this.pgAuthorityId = pgAuthorityId; } @OneToMany(fetch = FetchType.LAZY, mappedBy = "pgRoleId") public List<PgUser> getPgUsers() { return pgUsers; } public void setPgUsers(List<PgUser> pgUsers) { this.pgUsers = pgUsers; } }