java hibernate query language
TRANSCRIPT
-
8/11/2019 JAVA Hibernate Query Language
1/16
Apex T. G. India Pvt. Ltd
Hibernate QueryLanguage
http://apextgi.in/http://apextgi.in/ -
8/11/2019 JAVA Hibernate Query Language
2/16
1
HQL Hibernate Framework comes with a powerf!
ob"ect#oriented $er% !an&a&e ' Hibernate Qer%
Lan&a&e)HQL*.
It+s ver% simi!ar to ,QL except that we se -b"ects
instead of tab!e names that makes it more c!ose
to ob"ect oriented pro&rammin&.
Hibernate $er% !an&a&e is case#insensitive
except for "ava c!ass and variab!e names.
-
8/11/2019 JAVA Hibernate Query Language
3/16
1
HQL Hibernate Qer% Lan&a&e is sed to execte
$eries a&ainst database.
Hibernate atomatica!!% &enerates the s$! $er%
and execte it a&ainst nder!%in& database if HQL
is sed in the app!ication.
HQL is based on the re!ationa! ob"ect mode!s and
makes the ,QL ob"ect oriented.
-
8/11/2019 JAVA Hibernate Query Language
4/16
1
HQL Hibernate Qer% Lan&a&e is extreme!% powerf!
and it spports Po!%morphism Associations /ch
!ess verbose than ,QL.
0eason To se
F!! spport for re!ationa! operations HQL a!!ows
representin& ,QL $eries in the form of ob"ects.
Hibernate Qer% Lan&a&e ses 2!asses and
properties instead of tab!es and co!mns.
-
8/11/2019 JAVA Hibernate Query Language
5/16
1
HQL 0etrn res!t as -b"ect The HQL $eries retrn the
$er% res!t)s* in the form of ob"ect)s* which is
eas% to se. This e!iminates the need of creatin&
the ob"ect and pop!ate the data from res!t set.
Po!%morphic Qeries HQL f!!% spports
po!%morphic $eries. Po!%morphic $eries res!ts
the $er% res!ts a!on& with a!! the chi!d ob"ects if
an%.
-
8/11/2019 JAVA Hibernate Query Language
6/16
1
HQL 3as% to Learn Hibernate Qeries are eas% to !earn
and it can be easi!% imp!emented in the
app!ications.
,pport for Advance featres HQL contains man%
advance featres sch as pa&ination fetch "oin
with d%namic pro4!in& Inner5oter5f!! "oins
2artesian prodcts. It a!so spports Pro"ection
A&&re&ation )max av&* and &ropin& -rderin&
,b $eries and ,QL fnction ca!!s.
-
8/11/2019 JAVA Hibernate Query Language
7/16
1
HQL 6atabase independent Qeries written in HQL are
database independent )If database spports the
nder!%in& featre*.
7nderstandin& HQL ,%ntax
Hibernate Qer% Lan&a&e ma% consist of
fo!!owin& e!ements
2!ases
A&&re&ate fnctions
-
8/11/2019 JAVA Hibernate Query Language
8/16
1
HQL ,b $eries
2!ases in HQL
from
se!ect
where
order b%
&rop b%
-
8/11/2019 JAVA Hibernate Query Language
9/16
1
HQLA&&re&ate fnctions are
av&)...* sm)...* min)...* max)...*
cont)8*
cont)...* cont)distinct ...* cont)a!!...*
-
8/11/2019 JAVA Hibernate Query Language
10/16
1
HQL 2!ase
From 2!ase
It is same as se!ect c!ase in ,QL +from
3mp!o%ee+ is same as +se!ect 8 from 3mp!o%ee+. 9e
can a!so create a!ias sch as from 3mp!o%ee
emp or from 3mp!o%ee as emp.For 3xamp!e
session.createQer%):from3mp!o%ee:*;
-
8/11/2019 JAVA Hibernate Query Language
11/16
1
HQL
-
8/11/2019 JAVA Hibernate Query Language
12/16
1
HQL
A&&re&ate Fnctions
HQL spports common!% sed a&&re&ate fnctions
sch as cont)8* cont)distinct x* min)* max)*
av&)* and sm)* etc .For 3xamp!e
session.createQer%):se!ect sm)sa!* from ,tdent:*;
-
8/11/2019 JAVA Hibernate Query Language
13/16
1
HQL
3xpressions
HQL spports arithmetic expressions )> # 8 5*
binar% comparison operators )? @? ? @ B?
!ike* !o&ica! operations )and or not* etc. . For
3xamp!e session.createQer%):se!ect sa! from ,tdent whereid?1:*;
-
8/11/2019 JAVA Hibernate Query Language
14/16
1
HQL
HQL a!so spports order b% and &rop b% c!ases.
HQL a!so spports sb#$eries "st !ike ,QL
$eries.
HQL spports 66L 6/L and exectin& store
procedres too.
-
8/11/2019 JAVA Hibernate Query Language
15/16
1
2ontact s
-
8/11/2019 JAVA Hibernate Query Language
16/16
Thanks
facebook.com/apex.tgi
twitter.com/ApextgiNoida
pinterest.com/apextgi
Stay Connected with us for more chapters on JAVA
https://www.facebook.com/apex.tgihttps://twitter.com/ApextgiNoidahttp://www.pinterest.com/apextgihttp://www.pinterest.com/apextgihttp://www.pinterest.com/apextgihttps://twitter.com/ApextgiNoidahttps://twitter.com/ApextgiNoidahttps://www.facebook.com/apex.tgi