30 lines
824 B
Java
30 lines
824 B
Java
|
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;
|
||
|
}
|