All language subtitles for 003 Understand JPA Query and Named Query

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese Download
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:01,100 --> 00:00:08,058 Before implementing the listAll() and count() methods of the UserDAO class 2 00:00:08,800 --> 00:00:13,160 Let's understand how to execute a query in JPA 3 00:00:13,400 --> 00:00:18,800 because we need to use query in these methods 4 00:00:21,800 --> 00:00:27,500 This is a code examples that shows you how to execute a query that returns a single value 5 00:00:28,200 --> 00:00:29,900 a single result 6 00:00:30,600 --> 00:00:32,299 you can see the query here 7 00:00:32,500 --> 00:00:39,940 SELECT u from User u where u.email = 'billjoy@gmail.com' 8 00:00:41,900 --> 00:00:46,300 this is not standard SQL 9 00:00:46,500 --> 00:00:52,600 it's the JPQL or Java Persistence Query Language 10 00:00:53,200 --> 00:00:56,360 which is similar to a standard SQL 11 00:00:59,000 --> 00:01:08,100 this JPQL uses object-oriented syntax which is more convenient for programmers 12 00:01:09,900 --> 00:01:11,560 you can see 13 00:01:13,900 --> 00:01:15,440 you can see 14 00:01:16,200 --> 00:01:19,900 u.email here is object-oriented syntax 15 00:01:20,300 --> 00:01:28,610 it accesses the email field of the User object named u 16 00:01:30,900 --> 00:01:36,900 and the next statement creates a Query object from the query string 17 00:01:37,100 --> 00:01:43,900 and the getSingleResult() method executes the query and returns a single result 18 00:01:44,100 --> 00:01:50,000 such as an integer value, a String or an object 19 00:01:52,200 --> 00:01:57,640 and here's the second example that executes a query that returns a collection of values 20 00:01:57,640 --> 00:02:03,000 such as a list of mapped object from the database 21 00:02:07,100 --> 00:02:08,280 you can see 22 00:02:08,900 --> 00:02:14,500 we use the getResultList() method of the Query object 23 00:02:17,200 --> 00:02:25,300 this code executes the query that retrieves all rows from the table user 24 00:02:25,600 --> 00:02:32,500 and returns the result as a collection - a list of mapped User objects 25 00:02:32,900 --> 00:02:36,310 is very cool, isn't it? 26 00:02:42,000 --> 00:02:47,269 A named query in JPA is a query string which can be embedded with... 27 00:02:47,269 --> 00:02:52,200 in a model class using the annotation... 28 00:02:52,800 --> 00:02:54,000 you see 29 00:02:54,800 --> 00:03:02,000 the annotation @NamedQueries and @NamedQuery here 30 00:03:06,400 --> 00:03:07,260 you can see 31 00:03:07,500 --> 00:03:09,100 this annotation here 32 00:03:09,300 --> 00:03:14,600 this is the content of the query 33 00:03:14,700 --> 00:03:15,300 you see 34 00:03:15,600 --> 00:03:17,220 JPQL 35 00:03:18,400 --> 00:03:19,280 and... 36 00:03:19,500 --> 00:03:24,800 this is the name of the query: Users.findAll 37 00:03:24,900 --> 00:03:29,520 you can give it any name 38 00:03:30,600 --> 00:03:37,800 so the query can be referred by its name as shown in the code below 39 00:03:38,400 --> 00:03:39,780 you see 40 00:03:41,900 --> 00:03:47,900 From the entity manager we create a named query 41 00:03:48,020 --> 00:03:55,020 and refer to a named query by its name 42 00:03:58,920 --> 00:04:04,700 this line creates a Query object that refers to a query by its name 43 00:04:05,500 --> 00:04:10,600 JPA automatically loads named queries that are embedded in model classes 44 00:04:10,600 --> 00:04:14,080 so you can call them in your code 45 00:04:14,500 --> 00:04:22,000 the benefit of using named queries is that you can centralize related queries in one place 46 00:04:22,400 --> 00:04:31,500 typically in the model classes you can manage the queries easily when your code grows and become more complex 47 00:04:32,500 --> 00:04:33,840 as you can see 48 00:04:34,000 --> 00:04:42,320 The @NamedQueries annotation allows multiple @NamedQuery to be listed here 49 00:04:42,700 --> 00:04:51,790 so you can specify multiple named queries in a model class 3902

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.