package me.academeg.blog.dal.domain;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import org.hibernate.validator.constraints.NotBlank;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

/**
 * Tag Entity
 *
 * @author Yuriy A. Samsonov <yuriy.samsonov96@gmail.com>
 * @version 1.0
 */
@Setter
@Getter

@Entity
@Table(name = "tag")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, ignoreUnknown = true)
public class Tag {

    @Id
    @GenericGenerator(name = "uuid-gen", strategy = "uuid2")
    @GeneratedValue(generator = "uuid-gen")
    @Type(type = "uuid-char")
    private UUID id;

    @NotBlank
    @Column(nullable = false, unique = true)
    private String value;

    @JsonIgnore
    @ManyToMany(cascade = CascadeType.ALL, mappedBy = "tags", fetch = FetchType.LAZY)
    private List<Article> articles = new ArrayList<>();

    public Tag() {
    }

    public Tag(UUID uuid) {
        this.id = uuid;
    }
}

@@ -193,98 +193,8 @@
 er;%0A
-import org.hibernate.annotations.GenericGenerator;%0Aimport org.hibernate.annotations.Type;%0A
 impo
@@ -242,16 +242,16 @@
 tBlank;%0A
+
 %0Aimport 
@@ -605,174 +605,28 @@
 Tag 
-%7B%0A%0A    @Id%0A    @GenericGenerator(name = %22uuid-gen%22, strategy = %22uuid2%22)%0A    @GeneratedValue(generator = %22uuid-gen%22)%0A    @Type(type = %22uuid-char%22)%0A    private UUID id;
+extends BaseEntity %7B
 %0A%0A  
@@ -914,18 +914,16 @@
 ag(UUID 
-uu
 id) %7B%0A  
@@ -932,22 +932,17 @@
     
-this.id = uu
+super(
 id
+)
 ;%0A  

create base entity class