package org.apache.saltedpeanuts.model;

import com.bardframework.bard.core.marker.Model;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Date;

@Model
@Entity
public class Article {
    @Id @GeneratedValue(generator = "system-uuid")
    @GenericGenerator(name = "system-uuid", strategy = "uuid")
    @JsonPropertyDescription("The id of article")
    public String id;

    @Column
    @JsonPropertyDescription("The title of article")
    public String title;

    @Column @Lob
    @JsonPropertyDescription("Then content of article")
    public String content;

    @Column
    @JsonPropertyDescription("The create time of this article")
    public Date createdAt = new Date();

    @ManyToOne(fetch = FetchType.LAZY)
    @JsonPropertyDescription("The author of this article")
    public User author;

    public Article() {
    }

    public Article(String id) {
        this.id = id;
    }
}

@@ -148,16 +148,115 @@
 iption;%0A
+import org.hibernate.annotations.Cache;%0Aimport org.hibernate.annotations.CacheConcurrencyStrategy;%0A
 import o
@@ -366,16 +366,79 @@
 @Entity%0A
+@Cacheable%0A@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)%0A
 public c
@@ -966,32 +966,8 @@
 oOne
-(fetch = FetchType.LAZY)
 %0A   

revert "lazy fetch"