How to call native SQL queries with JPA and Hibernate

  Рет қаралды 4,312

Thorben Janssen

Thorben Janssen

Күн бұрын

JPQL is the most common way to query data from a database with JPA. It enables you to reuse your mapping definitions and is easier to use than SQL. But it supports only a small subset of the SQL standard, and it also provides no support for database-specific features.
So what shall you do if you need to use a database-specific query feature or your DBA gives you a highly optimized query that you can’t transform into JPQL? Just ignore it and do all the work in the Java code?
Of course not! JPA has its own query language, but it’s designed as a leaky abstraction and supports native SQL queries. You can create these queries in a similar way as JPQL queries, and they can even return managed entities if you want.
In this video, I will show you how to use native SQL queries, different options to map the query result to DTOs and entity objects and avoid a common performance pitfall.
Links mentioned in the video:
thorben-janssen.com/jpql/
thorben-janssen.com/dto-proje...
thorben-janssen.com/persist-p...
thorben-janssen.com/jpa-nativ...
thorben-janssen.com/jpa-2-2-r...
thorben-janssen.com/result-se...
thorben-janssen.com/result-se...
thorben-janssen.com/result-se...
thorben-janssen.com/result-se...
thorben-janssen.com/entities-...
thorben-janssen.com/hibernate...
thorben-janssen.com/hibernate...
thorben-janssen.com/tips-to-b...
Like my channel? Subscribe!
➜ bit.ly/2cUsid8
Read the accompanying post: thorben-janssen.com/jpa-nativ...
Want to connect with me?
Blog: thorben-janssen.com/
Twitter: / thjanssen123
Facebook: / thorbenjanssenofficial
Linkedin: / thorbenjanssen

Пікірлер: 8
@pathummadhusanka2496
@pathummadhusanka2496 2 жыл бұрын
No fancy stuff. Straight to the point. You always deliver quality and knowledge rich content. Thank you sir ❤
@enfieldli9296
@enfieldli9296 2 жыл бұрын
Really enjoy your work here, keep up the good stuff!
@sovrinfo
@sovrinfo 2 жыл бұрын
BIG BIG Thanks you!!
@orhankelesk2709
@orhankelesk2709 2 жыл бұрын
nice new look by the way, stick with it.
@jasper5016
@jasper5016 2 жыл бұрын
The most awaited video. Do we trade-off any performance with native queries? Can you pls share this source code on github?
@diniscab
@diniscab Жыл бұрын
Hi, I have quite a really specific problem that I wanted to find a solution for in this video. What is the best way, when using JPA with EclipseLink, to use the IN clause in a nativeQuery with EntityManager? I always have a lot of problems. Thanks in advance!
@mohangabhale5555
@mohangabhale5555 Жыл бұрын
I am using Linux Ubuntu os, i want hibarnate external jar files for eclipse
@nicholas1460
@nicholas1460 2 жыл бұрын
JPA is bloatware.
JPA & Hibernate: Using the Optimal Query Approach & Projection
11:13
Thorben Janssen
Рет қаралды 4,5 М.
5 Hibernate Features You Should Use With Spring Data JPA
11:21
Thorben Janssen
Рет қаралды 5 М.
Clown takes blame for missing candy 🍬🤣 #shorts
00:49
Yoeslan
Рет қаралды 49 МЛН
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 18 МЛН
Raw SQL, SQL Query Builder, or ORM?
16:19
ArjanCodes
Рет қаралды 97 М.
5 Tips To Write Efficient Queries With JPA And Hibernate
13:07
Thorben Janssen
Рет қаралды 10 М.
Ultimate Guide to Implementing Equals & HashCode with Hibernate & JPA
13:51
JPA & Hibernate: Basic Annotations You Need To Know
15:11
Thorben Janssen
Рет қаралды 30 М.
Spring Data JPA - Publishing Domain Events When Changing an Entity
10:49
Pydantic is all you need: Jason Liu
17:55
AI Engineer
Рет қаралды 173 М.
7 Database Design Mistakes to Avoid (With Solutions)
11:29
Database Star
Рет қаралды 69 М.
Spring Data JPA: Ultimate Guide to Custom Queries with @Query Annotation
15:09
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 256 М.
Сколько реально стоит ПК Величайшего?
0:37
Это iPhone 16
0:52
Wylsacom
Рет қаралды 786 М.
Bluetooth connected successfully 💯💯
0:16
Blue ice Comedy
Рет қаралды 1,6 МЛН
📱магазин техники в 2014 vs 2024
0:41
djetics
Рет қаралды 667 М.