EntityManagerFactory.getPersistenceUnitUtil().isLoaded(Object Entity);
entity.getClass();
Hibernate.initialize(entity);
단순히 Member 정보만 조작하는 로직이라면 필요 없을지도..?
비즈니스 로직상 Member만 자주 사용하는 경우
테이블이 수십 개 이상이면 많은 테이블에서 JOIN이 일어나서 성능 저하
Hibernate:
select
member0_.MEMBER_ID as MEMBER_I1_4_0_,
member0_.INSERT_MEMBER as INSERT_M2_4_0_,
member0_.createdDate as createdD3_4_0_,
member0_.UPDATE_MEMBER as UPDATE_M4_4_0_,
member0_.lastModifiedDate as lastModi5_4_0_,
member0_.LOCKER_ID as LOCKER_I7_4_0_,
member0_.name as name6_4_0_,
member0_.TEAM_ID as TEAM_ID8_4_0_,
locker1_.id as id1_3_1_,
locker1_.MEMBER_ID as MEMBER_I3_3_1_,
locker1_.name as name2_3_1_,
member2_.MEMBER_ID as MEMBER_I1_4_2_,
member2_.INSERT_MEMBER as INSERT_M2_4_2_,
member2_.createdDate as createdD3_4_2_,
member2_.UPDATE_MEMBER as UPDATE_M4_4_2_,
member2_.lastModifiedDate as lastModi5_4_2_,
member2_.LOCKER_ID as LOCKER_I7_4_2_,
member2_.name as name6_4_2_,
member2_.TEAM_ID as TEAM_ID8_4_2_,
team3_.TEAM_ID as TEAM_ID1_8_3_,
team3_.INSERT_MEMBER as INSERT_M2_8_3_,
team3_.createdDate as createdD3_8_3_,
team3_.UPDATE_MEMBER as UPDATE_M4_8_3_,
team3_.lastModifiedDate as lastModi5_8_3_,
team3_.name as name6_8_3_
from
Member member0_
left outer join
Locker locker1_
on member0_.LOCKER_ID=locker1_.id
left outer join
Member member2_
on locker1_.MEMBER_ID=member2_.MEMBER_ID
left outer join
Team team3_
on member2_.TEAM_ID=team3_.TEAM_ID
where
member0_.MEMBER_ID=?
Hibernate:
/* select
m
from
Member m */ select
member0_.MEMBER_ID as MEMBER_I1_4_,
member0_.INSERT_MEMBER as INSERT_M2_4_,
member0_.createdDate as createdD3_4_,
member0_.UPDATE_MEMBER as UPDATE_M4_4_,
member0_.lastModifiedDate as lastModi5_4_,
member0_.LOCKER_ID as LOCKER_I7_4_,
member0_.name as name6_4_,
member0_.TEAM_ID as TEAM_ID8_4_
from
Member member0_
Hibernate:
select
team0_.TEAM_ID as TEAM_ID1_8_0_,
team0_.INSERT_MEMBER as INSERT_M2_8_0_,
team0_.createdDate as createdD3_8_0_,
team0_.UPDATE_MEMBER as UPDATE_M4_8_0_,
team0_.lastModifiedDate as lastModi5_8_0_,
team0_.name as name6_8_0_
from
Team team0_
where
team0_.TEAM_ID=?
select * from Member
select * from Team where TEAM_ID = ???