Professional Documents
Culture Documents
Session03 Hibernate Queries
Session03 Hibernate Queries
Session03 Hibernate Queries
QUERIES INTRO
NATIVE SQL
Entity queries:
HQL
PROXY OBJECT
// Load Example
User user = (User) session.load(User.class, new Integer(2));
Basic It is used to fetch data from the It is also used to fetch data from the
database for the given identifier database for the given identifier
Null Object It object not found for the given It will throw object not found exception
identifier then it will return null object
Lazy or Eager It returns fully initialized object so this It always returns proxy object so this
loading method eager load the object method is lazy load the object
Use Case If you are not sure that object exist then If you are sure that object exist then use
use get() method load() method
43e-BM/HR/HDCV/FSOFT V1.2 - ©FPT SOFTWARE - Fresher Academy - Internal Use 15
Lecture 06
session.evict(person);
person.setName("Mary");
person.setName("Mary");
session.update(person);