entity.Direction.java Source code

Java tutorial

Introduction

Here is the source code for entity.Direction.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import entity.parent.PrimEntity;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.apache.commons.lang3.StringEscapeUtils;
import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.NotEmpty;
import support.ErrorMess;

/**
 * 
 *
 * @author Rice Pavel
 */
@Entity
@Table(name = "direction")
public class Direction extends PrimEntity {

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

    @NotEmpty(message = "?: " + ErrorMess.NOT_EMPTY)
    @Column(name = "name")
    private String name;

    /**
     * ? ?   
     */
    @Column(name = "name_for_shop")
    private String nameForShop;

    @ManyToMany(targetEntity = Author.class, mappedBy = "directions")
    @LazyCollection(LazyCollectionOption.TRUE)
    private List<Author> authors;

    @ManyToMany(mappedBy = "directions")
    @LazyCollection(LazyCollectionOption.TRUE)
    private List<Order> orders;

    public String getNameForShop() {
        return StringEscapeUtils.escapeHtml4(nameForShop);
    }

    public void setNameForShop(String nameForShop) {
        this.nameForShop = nameForShop;
    }

    public List<Author> getAuthors() {
        return authors;
    }

    public void setAuthors(List<Author> authors) {
        this.authors = authors;
    }

    public List<Order> getOrders() {
        return orders;
    }

    public void setOrders(List<Order> orders) {
        this.orders = orders;
    }

    public Long getDirectionId() {
        return directionId;
    }

    public void setDirectionId(Long directionId) {
        this.directionId = directionId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public Long getId() {
        return directionId;
    }

}