Тёмный
No video :(

How to Return DTOs from Native Queries with Spring Data JPA 

Thorben Janssen
Подписаться 40 тыс.
Просмотров 35 тыс.
50% 1

When using Spring Data JPA, you are used to derived and custom queries that return the result in your preferred format. A typical example is a DTO projection, which is the most efficient one for read-only operations. To use it in a derived or custom JPQL query, you only need to change the return type of your repository method to your DTO class or interface. But when using a native query, some limitations make DTOs a little harder to use.
Links mentioned:
Composite Repositories - Extend your Spring Data JPA Repository: thorben-jansse...
How to Use Named Queries with Spring Data JPA : thorben-jansse...
Result Set Mapping: Constructor Result Mappings
thorben-jansse...
Like my channel? Subscribe!
➜ bit.ly/2cUsid8
Join the free Member Library:
goo.gl/dtyIIC
Read the accompanying post: thorben-jansse...
Want to connect with me?
Blog: thorben-jansse...
Twitter: / thjanssen123
Facebook: / thorbenjanssenofficial
Linkedin: / thorbenjanssen
#SpringDataJPA #ReturnDTOs #NativeQuery

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 35   
@rohanbipetkar3800
@rohanbipetkar3800 2 года назад
I was getting this ConverterNotFoundException, searched alot about this but didn't find anything specific. Found this video which is extremely helpful
@haoxu3515
@haoxu3515 2 года назад
This tutorial is super concise and accurate. It accurately answered the questions most likely to be asked by fresh learners like me..
@kennedmena4121
@kennedmena4121 2 года назад
wao I did save a lot of time just doing the first scenario, making an interface for getting the data. thanks a lot
@andreafranceschini2400
@andreafranceschini2400 2 года назад
A good tutorial that makes things clear and simple. It helped me to solve a problem. One thing: in the repository definition of the query I had to use (@Param("id") Long id) instead of (Long id) to make it work. 👍
@andreafranceschini2400
@andreafranceschini2400 2 года назад
and yes, I subscribed to the channel 🙂
@nitinsoni3358
@nitinsoni3358 Месяц назад
Good work, thanks
@ASSASIN299
@ASSASIN299 Год назад
Thanks my friend, just what I needed
@srikanthkadiyala5971
@srikanthkadiyala5971 Месяц назад
Good Morning, I have a scenario to fetch the data from teradata sql views by using spring-boot-data-jpa with no primary key column in database. 1. When using entity it is expecting primary key but we don't have the PK ID column in database. Existing behaviour of data mapping: They joined multiple views and getting the data and mapping DTO class by using RowMapper with spring-boot < 3.x Expected: After >3.x spring-boot version upgrade data binding is not happening. If you have any idea that would be great helpful to me?? Thanks Note:I have done the all the code change related to JPA but getting the Exception like ID column not found in database because as mentioned don't have Id column in views..
@ModifiedGaddiyan
@ModifiedGaddiyan 2 месяца назад
tell me when query gives you list of names then how to get that list?
@abhisheksuryawanshi9102
@abhisheksuryawanshi9102 2 года назад
GOD LEVEL TOUTORIAL
@profebuka
@profebuka 3 года назад
Good content but it's complex. JPA can execute with native query to return the entity class. Then I can map the enity class to the dto.
@danykoudja168
@danykoudja168 3 года назад
Unfortunately, the entire entity graph of your entity class is loaded before you map it to your dto. With the approach presented, the projection on the fields you need in your dto are directly made during the SQL query. So your query becomes faster.
@Denys.Stoianov
@Denys.Stoianov 3 года назад
This is the good things, but I didn't get how it works, I need to try it in ide. Maybe in next video if is possible to show how it works in IDE with real coding for better understanding 🤔
@niiel98
@niiel98 Год назад
YOU ARE AMAZING!!!!! THANKS!!!!!
@anjanx44
@anjanx44 Год назад
Thanks man you save my lots of time ❤
@kushalyeluri5793
@kushalyeluri5793 Год назад
If I use namednativequery with custom DTO using sqlresultsetmapping. Is it possible to perform pagination for that?
@yousufbaig821
@yousufbaig821 2 года назад
Superb video !! Thanks a lot. This helped me a lot.
@azizbekibnhamid642
@azizbekibnhamid642 Год назад
Thank you very much
@ekaterinagalkina7303
@ekaterinagalkina7303 3 года назад
p.first_name as firstName. But what would be the alias for a nested object? For example, address.street as {what?} (assuming that PlayerName references Address)?
@menssageiro01
@menssageiro01 Год назад
kkk, mais uma vez precisei assistir esse vídeo.
@yyyyyyyyyyy1988
@yyyyyyyyyyy1988 2 года назад
Thanks alot sir, you saved my day
@paolofrancescosciammarella1420
@paolofrancescosciammarella1420 2 года назад
Amazing! Thank u so much!
@urrahman196
@urrahman196 2 года назад
Hello, Can you please make a tuto or blog on - how to do the scalar projection? Got few lines in tour blog but not details implementation, I am talking about the object[ ] way to implement DTO
@menssageiro01
@menssageiro01 3 года назад
Muito Obrigado pela aula.
@bareetsingh
@bareetsingh 2 года назад
Thank you, so much sir.
@KrishnaKishore
@KrishnaKishore 2 года назад
@Thorben Can I export these Repos as a Jar and use them in different projects?
@TrinhNguyen-lf6zp
@TrinhNguyen-lf6zp 2 года назад
sorry, i fail with field id data type bigint sqlserver -> data type java Long. Exception: Could not locate appropriate constructor on class: xxxDto
@yamincires5313
@yamincires5313 3 года назад
I love your content :)
@ThoughtsOnJava
@ThoughtsOnJava 3 года назад
Thank you.
@MarkVeronica-z3s
@MarkVeronica-z3s 2 часа назад
Harris David Rodriguez Jose Harris Mary
@marcelbartholome5629
@marcelbartholome5629 3 года назад
Hi, Thorben, ich mag deine Videos sehr und habe normal auch kein Problem, diese in englischer Sprache zu hören, aber manchmal wäre es auch cool sie zusätzlich in deutsch anschauen zu können. vll. denkst du mal darüber nach auch deutsche Untertitel einzubauen. Mach Weiter so!
@SohelRana4-m5c
@SohelRana4-m5c 4 дня назад
Walker Brenda Rodriguez Ronald Taylor Betty
@EtanRowleS
@EtanRowleS 3 дня назад
Jones Sandra Garcia Dorothy Walker Margaret
@SoutheyYale
@SoutheyYale 2 дня назад
White Larry Martinez Melissa Johnson Nancy
@ShinAkuma
@ShinAkuma 2 года назад
That's too much code. Just use " select new MyPojo( a.col1, a.col2... ) from Table a"
Далее
How to call native SQL queries with JPA and Hibernate
13:46
MILLION JAMOASI 2024 4K
2:17:51
Просмотров 13 млн
Use DTO instead of Model and Entity objects
8:11
Просмотров 21 тыс.
JPA & Hibernate: Basic Annotations You Need To Know
15:11
Spring & Spring Data JPA: Managing Transactions
10:34
Spring Data JPA -Criteria Queries - The Full Guide
30:07
#17 Spring Data JPA
11:01
Просмотров 12 тыс.
🍃 Introduction to Spring GraphQL with Spring Boot
19:14
MILLION JAMOASI 2024 4K
2:17:51
Просмотров 13 млн