작성
·
86
0
강의하신 코드랑 같고
try {
Team team = new Team();
team.setName("teamA");
em.persist(team);
Member member = new Member();
member.setUsername("member");
member.setAge(10);
member.setTeam(team);
em.persist(member);
em.flush();
em.clear();
String query = "select m from Member m left join m.team t";
List<Member> result = em.createQuery(query, Member.class)
.getResultList();
tx.commit();
} catch (Exception e) {
tx.rollback();
e.printStackTrace();
} finally {
em.close();
}
결과
Hibernate:
/* select
m
from
Member m
left join
m.team t */ select
m1_0.id,
m1_0.age,
m1_0.TEAM_ID,
m1_0.username
from
Member m1_0
left join이 안나가네요, jpql로 join까지 썻는데 왜 안나가는걸까요