Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.handong.cra.crawebbackend.user.domain.User;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.BatchSize;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;
import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;

Expand Down Expand Up @@ -43,9 +44,11 @@ public class Board extends BaseEntity {
@Setter
private List<String> imageUrls = new ArrayList<>();

@BatchSize(size = 100)
@OneToMany(mappedBy = "board", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Comment> comments;

@BatchSize(size = 100)
@ManyToMany(mappedBy = "likedBoards")
private List<User> likedUsers = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public interface BoardRepository extends JpaRepository<Board, Long> {

List<Board> findAllByCategoryAndDeletedFalse(Category category);

@Query("SELECT b FROM Board b JOIN FETCH b.user WHERE b.category = :category AND b.deleted = false")
Page<Board> findAllByCategoryAndDeletedFalse(Category category, Pageable pageable);

@EntityGraph(attributePaths = {"likedUsers"})
Optional<Board> findBoardByIdAndDeletedFalse(Long id);

List<Board> findByCategory(Category category);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class User extends BaseEntity {
@Column(name = "github_id", nullable = false)
private String githubId;


private UserRoleSet roles;

@Column(name = "student_id", unique = true, nullable = false)
Expand All @@ -46,7 +47,7 @@ public class User extends BaseEntity {
@Column(name = "img_url")
private String imgUrl;

@ManyToMany(fetch = FetchType.EAGER)
@ManyToMany(fetch = FetchType.LAZY)
@JoinTable(
name = "likes",
joinColumns = @JoinColumn(name = "user_id"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@Embeddable
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class UserRoleSet {
@ElementCollection(fetch = FetchType.EAGER)
@ElementCollection(fetch = FetchType.LAZY)
@CollectionTable(name = "roles", joinColumns = @JoinColumn(name = "user_id"))
@Enumerated(EnumType.STRING)
private Set<UserRoleEnum> roles = new HashSet<>();
Expand Down
Loading