5 Tips To Write Efficient Queries With JPA And Hibernate
HTML-код
- Опубликовано: 2 дек 2024
- A lot of developers seem to have a love-hate relationship with JPA and Hibernate. They love it because it makes it easy to implement most use cases and they hate it because it also makes it easy to implement very inefficient queries.
In the past, I was one of these developers myself. I liked to use Hibernate, but I also struggled with slow database queries and other performance issues. That changed over the years when I spend more and more time working with and teaching about Hibernate.
When you analyze enough inefficient queries, you recognize that you just have to follow a few simple recommendations to avoid most of them.
If you like this video, please give me your thumbs up and share it with your friends and co-workers.
Like my channel? Subscribe!
➜ bit.ly/2cUsid8
Join the free Member Library:
goo.gl/dtyIIC
Read the accompanying post: www.thoughts-o...
Want to connect with me?
Blog: www.thoughts-on...
Twitter: / thjanssen123
Facebook: / thoughtsonjava
#JPA #Hibernate #queries #performance tuning
Hi! your tutorials are great for beginners like me. Could you please explain the recursive json problem in many-to-many mapping, as well as complex filter queries in jpa hibernate that take on dynamic list as a parameter.
I think lots of people would be grateful to you, if u could extend the Entity Graph and Join Fetch with Criteria part of this video. Maybe with some use cases as usual. Pls do a dedicated video..This could help expecially because of the new 2.1 specs around.
Hi,
Thanks for your comment.
I explain EntityGraph and @NamedEntityGraph in more details in this video: ruclips.net/video/Dr5Qn6NC-3Y/видео.html
And I wrote about it in these posts:
www.thoughts-on-java.org/2014/03/jpa-21-entity-graph-part-1-named-entity.html
www.thoughts-on-java.org/2014/04/jpa-21-entity-graph-part-2-define.html
Regards,
Thorben
Hibernate is not properly populating the primary keys which are sequence generated if fetch type Eager isn't used. I am guessing the work around on this is to create the child entities first and then populate the relationships. There seems to be a lot of work arounds in hibernate. There is a ton of does and don'ts when working with hibernate, hell Thorben, you've made a living out of documenting them and giving classes on them. Why not just learn and use SQL and use JDBC to get all the data that is needed for each of the queries? That is my recommendation for the future.
thanks