Skip to content

Instantly share code, notes, and snippets.

@haishengwu-okta
Last active August 24, 2017 05:30
Show Gist options
  • Save haishengwu-okta/2e5c34b012bcb5e5e41c59a6863846c9 to your computer and use it in GitHub Desktop.
Save haishengwu-okta/2e5c34b012bcb5e5e41c59a6863846c9 to your computer and use it in GitHub Desktop.
Hello Hibernate
data Teacher = T { students :: [Student]
                 , departs :: [Department]
                }
-- Student and Department do not matter so far
-- HQL

1. select Teacher where id = 'abc';
2. then hibernate will eager fetch students and departs with extra 2 queries;


-- SQL
-- results size = N * M, given Student.size is N and Department.size is M
select * from Teacher
join Student ...
join Department ...
where Teacher.id = 'abc';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment