backend-demo-tn/src/main/java/com/cubetiqs/demo/domain/PostEntity.java

30 lines
824 B
Java
Raw Normal View History

2020-06-10 19:38:38 +07:00
package com.cubetiqs.demo.domain;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import javax.persistence.*;
import java.util.Collection;
import java.util.List;
@Entity
@Table(name = "posts")
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PostEntity extends BaseEntity<Long> {
@Column
private String title;
@Column(columnDefinition = "TEXT")
private String contents;
@ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.REFRESH, CascadeType.DETACH})
@JoinColumn(name = "user_id")
private UserEntity user;
@OneToMany(mappedBy = "post", fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, orphanRemoval = true)
private Collection<CommentEntity> comments;
}