package com.ibtp.kontor.library.entity;

import javax.persistence.*;

/**
 * Created by TPEETZ on 23.01.2015.
 */
@NamedQueries({
        @NamedQuery(name="Article.findAll", query="SELECT a from ArticleEntity as a"),
        @NamedQuery(name="Article.findByTitle", query="SELECT a from ArticleEntity as a WHERE a.title = :title")
})

@Entity
@Table(name = "ARTICLE")
public class ArticleEntity {

    private Long id;

    private String title;

    private AuthorEntity author;

    public ArticleEntity() {}

    public ArticleEntity(String title) {
        setTitle(title);
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

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

    @Column
    public String getTitle() {
        return title;
    }

    void setTitle(String title) {
        this.title = title;
    }

    @ManyToOne
    public AuthorEntity getAuthor() {
        return author;
    }

    public void setAuthor(AuthorEntity author) {
        this.author = author;
    }
}
