Fetch Join(2)
-
Hibernate 5와 6에서 fetch join, @BatchSize 그리고 페이징 처리
hibernate 6 버전에서는 아래와 같이 fetch join을 할 경우 자동으로 중복된 데이터(Nationality의 id값이 같은 경우)는 제거해준다고 한다. 참고자료(https://docs.jboss.org/hibernate/orm/current/userguide/html_single/Hibernate_User_Guide.html#hql-distinct)@Query("select n from Nationality n join fetch n.players p left join fetch p.club")List findAllByFetchJoin();하지만 그 미만의 버전에서는 이런 기능이 없었기 때문에 distinct를 붙여줘야 한다.@Query("select distinct n from Nation..
2024.09.20 -
OneToMany, ManyToOne 테스트
@NoArgsConstructor@AllArgsConstructor@Getter@Entitypublic class Nationality { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @Column(unique = true) private String name; @OneToMany private List players; @Enumerated(EnumType.STRING) private Continent continent;}@Getter@NoArgsConstructor@AllArgsConstructor@Entitypublic class Player { @Id @G..
2024.09.16