No video

Spring Data JPA: Query Projections

  Рет қаралды 18,991

Thorben Janssen

Thorben Janssen

3 жыл бұрын

The Projection is one of the first things you’re probably thinking about when implementing a query with Spring Data JPA. This is because projection defines the entity attributes and the database columns returned by your query. So, selecting the right columns is important for your business logic. At the same time, projection is also crucial for the performance of your application and the maintainability of your code. In addition, you need to choose a projection that keeps the overhead as low as possible and provides the data in an easy to use structure.
In this video, I will show you all the query projections supported by Spring Data JPA and which one you should use.
Links mentioned:
Entities or DTOs - When should you use which projection? : thorben-janssen.com/entities-...
Like my channel? Subscribe!
➜ bit.ly/2cUsid8
Join the free Member Library:
goo.gl/dtyIIC
Read the accompanying post: thorben-janssen.com/spring-da...
Want to connect with me?
Blog: thorben-janssen.com/
Twitter: / thjanssen123
Facebook: / thoughtsonjava
#Spring #JPA #Query #Projections

Пікірлер: 17
@andromadusnaruto1544
@andromadusnaruto1544 3 жыл бұрын
Good day, @Thorben. I've been subscribed to your mailing list for a while and I've enjoyed your awesome content, especially with regards to Java Hibernate framework. My first time being on the channel. I wish you the best. I have committed to learning Spring framework + Hibernate framework by the end of this year or early next year. I have good practical knowledge of Java and OOP design principles.
@sergiowwwat
@sergiowwwat 3 жыл бұрын
That was great! I didn't know that spring could fetch entity properties in a DTO projection based on parameter names on the constructor! I always coded the constructor expression in the query...
@davidfelipegarciasegura8863
@davidfelipegarciasegura8863 3 жыл бұрын
Great tutorial, thanks.
@ronaldcastaneda2547
@ronaldcastaneda2547 3 жыл бұрын
You are the best, thanks for the information.
@cinemaismywife
@cinemaismywife 3 жыл бұрын
Great tutorial, Please tell me how to fetch child data by a certain field from parent using spring projections. Thanks. Subscribed!
@ebichu8126
@ebichu8126 3 жыл бұрын
Hey Thorben, Thanks for your great video. I see many people are using JDBC template for fetching DTO because it is highly customizable. But I think JDBC template is easily messed up, and error-prone, and it is not readable when the query takes dynamic WHERE conditions. Could you let us know there is any benefit to use JDBC template against Spring Projection when it comes to outbound DTO projection? Thanks!
@khairnarshekhar
@khairnarshekhar 3 жыл бұрын
I'm using Interface projtion and one of the get method in interface of type OffsetDateaTime but it's giving error.. could you please shade some light on the issu
@chiths
@chiths 3 жыл бұрын
Good video .. can u please do a lesson based on using Criteria Builder with associations (joins)
@gurugovindgarg3771
@gurugovindgarg3771 3 жыл бұрын
Great tutorial, How can we populate interface projection from Json file for testing
@vinaykaushikinvisble
@vinaykaushikinvisble 3 жыл бұрын
Is projection can me mixed with specification?
@cinemaismywife
@cinemaismywife 3 жыл бұрын
Please tell me how to fetch child data by a certain field from parent using spring projections.
@mukhirais6557
@mukhirais6557 2 жыл бұрын
How to pass associate object in constructor in JPQL query. Just u have shown only passing properties not obj.
@anjanx44
@anjanx44 Жыл бұрын
Great content, but how to use class dto for store procedure?
@kennyng9684
@kennyng9684 3 жыл бұрын
Good day @Thorben, i have a use case which i'm trying to glue graphql with jpa. The problem is queries from graphql are dynamic. They are then converted to JPA CriteriaQuery to generate projections and predicates to construct SQL. I need to map my resultset back to the JPA entity. I have tried AliasToBeanResultTransformer to auto-map my projections. I'm using hibernate beneath it. Unfortunately, I realised JPA CriteriaQuery converted to HQL is not producing aliases in the projection although I have configured aliases. This result in AliasToBeanResultTransformer not able to map the resultset back to the entity attributes. Do you have any reccomendation?
@jayashreeerrabelli4258
@jayashreeerrabelli4258 3 жыл бұрын
How did you resolve this ? It is expecting a constructor for every combination of attributes in select and groupby clauses, I have configured aliases too but nothing seems to work
@kennyng9684
@kennyng9684 3 жыл бұрын
@@jayashreeerrabelli4258 yes, in the end, i did a walkaround and rewrite the jpql to create the alias myself
@Quester82
@Quester82 2 жыл бұрын
When you need a class based DTO projection you can't use nested fields. There is no support for this out of the box. If you want to get unmanaged entity with nested fields like Collection you'll have to resort to using tools like Mapstruct. That was a real downside for me. Manageable but a downside non the less.
5 Hibernate Features You Should Use With Spring Data JPA
11:21
Thorben Janssen
Рет қаралды 5 М.
How to call native SQL queries with JPA and Hibernate
13:46
Thorben Janssen
Рет қаралды 4,3 М.
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 22 МЛН
Ouch.. 🤕
00:30
Celine & Michiel
Рет қаралды 26 МЛН
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 68 МЛН
JPA & Hibernate - Why, When & How to use DTO Projections
10:38
Thorben Janssen
Рет қаралды 16 М.
Spring Data JPA Projections | SoftTeco Meetup
26:57
SoftTeco Team
Рет қаралды 1 М.
Spring Tips: Spring Modulith
37:39
SpringDeveloper
Рет қаралды 20 М.
Ultimate Guide: Derived Queries with Spring Data JPA
10:14
Thorben Janssen
Рет қаралды 14 М.
JPA & Hibernate: Using the Optimal Query Approach & Projection
11:13
Thorben Janssen
Рет қаралды 4,5 М.
JPA & Hibernate: Basic Annotations You Need To Know
15:11
Thorben Janssen
Рет қаралды 30 М.
Spring & Spring Data JPA: Managing Transactions
10:34
Thorben Janssen
Рет қаралды 63 М.
Best Toilet Gadgets and #Hacks you must try!!💩💩
00:49
Poly Holy Yow
Рет қаралды 22 МЛН