![Vlad Mihalcea](/img/default-banner.jpg)
- Видео 20
- Просмотров 147 880
Vlad Mihalcea
Румыния
Добавлен 11 май 2012
Welcome to my High-Performance Java Persistence Video Channel.
Subscribe to my channel and get to learn more about JPA, Hibernate, Java and Database Systems.
Subscribe to my channel and get to learn more about JPA, Hibernate, Java and Database Systems.
Tuning the JPA and Hibernate mappings of a Spring e-commerce application
This is the third episode of the series, in which we are fixing the JPA and Hibernate mapping issues reported by Hypersistence Optimizer when analyzing the Shopizer OSS project.
If you haven't watched the first and the second episodes, you may want to start with those:
• ruclips.net/video/Z4FsIMksTBk/видео.html
• ruclips.net/video/gx5pi-wKrcA/видео.html
The GitHub repository used in this video can be located here:
github.com/vladmihalcea/shopizer
And the Hypersistence Optimizer tool we are using can be found here:
vladmihalcea.com/hypersistence-optimizer/
If you haven't watched the first and the second episodes, you may want to start with those:
• ruclips.net/video/Z4FsIMksTBk/видео.html
• ruclips.net/video/gx5pi-wKrcA/видео.html
The GitHub repository used in this video can be located here:
github.com/vladmihalcea/shopizer
And the Hypersistence Optimizer tool we are using can be found here:
vladmihalcea.com/hypersistence-optimizer/
Просмотров: 2 491
Видео
Tuning the JPA and Hibernate configurations of a Spring e-commerce application
Просмотров 1,5 тыс.Год назад
This is the second episode of the series, in which we are fixing the JPA and Hibernate configuration issues reported by Hypersistence Optimizer when analyzing the Shopizer OSS project. If you haven't watched the first episode, you may want to start with that one 👇: ruclips.net/video/Z4FsIMksTBk/видео.html And afterward, you can watch the next part in which we are going to fix the JPA and Hibern...
Tuning a Spring e-commerce application using Hypersistence Optimizer
Просмотров 4 тыс.Год назад
1️⃣ This is the first episode of the series, in which we are investigating the performance tuning issues reported by Hypersistence Optimizer when analyzing the Shopizer OSS project. The GitHub repository used in this video can be located here: github.com/vladmihalcea/shopizer And the Hypersistence Optimizer tool we are using can be found here: vladmihalcea.com/hypersistence-optimizer/ 2️⃣ If yo...
The best way to map the JPA and Hibernate ManyToMany relationship
Просмотров 7 тыс.Год назад
In this video episode, I’m going to show you the best way to map a ManyToMany association when using JPA and Hibernate. As simple as JPA annotations might be, it’s not always obvious how efficient they are behind the scenes.
The best way to fetch entities with JPA and Hibernate
Просмотров 3,3 тыс.Год назад
In this video, we are going to talk about fetching JPA and Hibernate entities. First, I'm going to explain how you fetch entities directly via their entity identifier or natural identifier. Afterward, we are going to see how we can fetch entities via JPQL, SQL, and Criteria API queries. In the end, I'm going to explain how the JPA entity Metamodel works and why you should use it when building d...
The best way to fetch SQL query projections with JPA
Просмотров 4,2 тыс.Год назад
Learn what the best way you can fetch SQL query projections when using JPA. In this video, you are going to learn: 1️⃣ How the default Object[] query projection works 2️⃣ How to use the JPA Tuple for query projections 3️⃣ How to fetch DTO projections using JPA 4️⃣ How to use Java Records with JPA query projections
The best way to map a @OneToOne relationship with JPA and Hibernate
Просмотров 9 тыс.Год назад
In this video, we are going to learn the best way to map a @OneToOne association with JPA and Hibernate. While there are many ways you can map a one-to-one relationship with Hibernate, I’m going to demonstrate which mapping is the most efficient one from a database perspective.
How to use the SQL EXISTS and NOT EXISTS conditional operators
Просмотров 16 тыс.2 года назад
In this video, we are going to see how the SQL EXISTS and NOT EXISTS operators work and when you should use them. Although these operators have been available since SQL:86, the very first edition of the SQL Standard, I found that there are still many application developers who don’t realize how powerful SQL subquery expressions really are when it comes to filtering a given table based on a cond...
How do SQL Recursive CTE queries work
Просмотров 4,4 тыс.2 года назад
In this video, you are going to learn how SQL Recursive CTE queries work. This video is part of my HIgh-Performance SQL video course, so if you liked this video, you are going to love my video course. vladmihalcea.com/courses/high-performance-sql/
Spring Boot Performance Workshop with Lightrun
Просмотров 8 тыс.2 года назад
In this workshop, you will learn how to identify the cause of various Spring Boot performance issues on a live production system using Lightrun. Lightrun is a developer-centric observability platform that allows you to add logs and metrics, as well as capture snapshots in real-time and on-demand, without having to redeploy your production system. Check out the following link if you'd like to gi...
The best way to map a bidirectional JPA OneToMany relationship
Просмотров 16 тыс.3 года назад
Learn how to map a bidirectional JPA OneToMany relationship using the ManyToOne and OneToMany annotations.
How does the JDBC Statement Fetch Size work
Просмотров 2,9 тыс.4 года назад
Learn how the JDBC Statement Fetch Size works and what's the best value to use by default depending on the underlying database system (e.g., Oracle, SQL Server, PostgreSQL or MySQL).
How to speed up database integration tests using Docker and tmpfs
Просмотров 2,5 тыс.4 года назад
In this video, I'm going to demonstrate how you can speed up database integration tests using Docker and tmpfs. By using this strategy, you will be able to run MySQL or PostgreSQL integration tests almost as fast as when using an in-memory database, like H2 or HSQLDB. This video is a sample of my High-Performance Java Persistence video course. So, if you like it, you are going to love the entir...
How to write Criteria API queries using Codota
Просмотров 3,6 тыс.5 лет назад
Codota is a code completion Java IDE tool that uses Artificial Intelligence to provide suggestions based on the most common ways of using a certain API. In this episode, we are going to see how we can use Codota to simplify the process of writing JPA Criteria API queries. You can get Codota (which is free, by the way) here: vladmihalcea.com/try-codota This research was funded by Codota and cond...
Tuning Spring PetClinic JPA and Hibernate configuration with Hypersistence Optimizer
Просмотров 19 тыс.5 лет назад
In this video, we are going to see how we can tune the performance of the Spring PetClinic application using Hypersistence Optimizer. Now, while you can manually analyze your data access layer to make sure that JPA and Hibernate are properly configured, it’s much better if you can automate this task. That’s because new entities might be mapped in the future, and you want to make sure that the s...
The best way to batch insert, update, and delete statements with JPA and Hibernate
Просмотров 21 тыс.5 лет назад
The best way to batch insert, update, and delete statements with JPA and Hibernate
Why you should use my high-performance-java-persistence GitHub repository
Просмотров 6 тыс.6 лет назад
Why you should use my high-performance-java-persistence GitHub repository
How to integrate a GitHub Pull Request using interactive rebase and squashing commits
Просмотров 2,2 тыс.6 лет назад
How to integrate a GitHub Pull Request using interactive rebase and squashing commits
What is the Lost Update anomaly and the best way to fix it
Просмотров 3,4 тыс.6 лет назад
What is the Lost Update anomaly and the best way to fix it
The best way to log SQL statements with JPA and Hibernate
Просмотров 13 тыс.7 лет назад
The best way to log SQL statements with JPA and Hibernate
Lopez Paul Davis Ronald Thomas Sandra
i think they removed hypersistence-optimizer library in the latest version. [EDIT]: moved*
What do you mean? Who are they? And what was moved?
@@vladmihalcea well when i try adding the dependency in my pom it didnt work the artifactId "hypersistence-optimizer" wasn't available but instead i found "hypersistence-utils-hibernate-60" in maven so when i try with this it was not there. So i thought it migh be moved to someplace else in the utils...i think i need to look around more And i think they is you😅
@@howto...6298 The project is not open source, so it's not on Maven Central. You have to install it from the package you downloaded from Teachable, following the links from my website.
Great video, Vlad. Thank you very much.
I'm glad you liked it. This video is part of my High-Performance Java Persistence video course, so if you liked this video, you are going to love the video course. vladmihalcea.com/courses/high-performance-java-persistence/
@@vladmihalcea I am convinced that your course is flawless and will provide invaluable experience for students, beginners and experienced staff. Thank you for sharing your expertise. The future lies with smart and kind people. You're part of the future, Vlad.
Hello , Mr Vlad Thanks so munch for this amazing video , thanks to you I have improved performance and my applications are faster
You're welcome. I'm glad I could help.
hello there thanks for this amazing video i wanted to ask can i have a projection with postDTO and in it a list of PostCmmecntsDto and if so what is the jpql query to return will be like ?
Yes, you can. Check out this article for more details: vladmihalcea.com/one-to-many-dto-projection-hibernate/ If you prefer a video explanation, then check out my video course as well: vladmihalceastore.teachable.com/p/high-performance-java-persistence-online
@@vladmihalcea very nice article i got it now thank you so much
Best explanation I've ever seen. Thank You for explaining this. Your video deserves a million views
You're welcome. This video is an episode of my High-Performance Java Persistence video course. If you liked the video, you are going to love the 11-hour video course vladmihalcea.com/courses/high-performance-java-persistence/
very good lecture, many tks!
You're welcome. If you liked this snippet, you are going to love the video course where this snippet is coming from: vladmihalcea.com/courses/high-performance-java-persistence/
5:40 How are you gonna have your stupid face cover up a box we're supposed to read and a link to a video covering up the student_grade table that we need to look at? I was trying really hard to understand your explanation, but this really pissed me off that I wasted 6 minutes of my life on your stupid video. Terrible
Great video. Vlad, thanks for many tutorials, your jpa skills are amazing!
Thanks and stay tuned for more
Nice explanation!
Thanks. This video is a lesson from my HIgh-Performance SQL video course, so if you liked it, you are going to love the video course. vladmihalceastore.teachable.com/p/high-performance-sql-online?coupon_code=BLACKFRIDAY23
Good job, thanks for posting to clarify it better for us. But, if you don't mind, this is for 10th grade delineation. And not having a grade score of 10 (and if you meant 10th grade, apologies in advance). Never mind, I see later on that you 'are' talking grades of 10, 9, 8, etc...
In Europe, where I live, many countries use the 0-10 grade system, where 10 is the highest score. www.nuffic.nl/en/education-systems/european-baccalaureate/grades-and-study-results Hence, the example in this video.
brilliant! can't wait for more videos on this series
In my opinion, it's much simpler to just keep all three tables as the ones without any *ToMany relations and do all the stuff by hand. Looking at the complexity of the utility methods, as well as mapping verbosity of the entities, it will be easier to do all the activities in the code directly (better to read, better to modify and support). For example, if we need to add a new many-to-many relation, we just persist manually all two parents and then add a new entity representing many-to-many relation. The same is about removal - just remove the desired record(s) from the join table, and then delete the parent ones!
You can map the intermediary table as an entity and get both the convenience of the entity relationship and the flexibility of adding new columns and get the same performance of doing the operations manually.
@@vladmihalcea Thanks for your reply. I don't have the finite opinion on that, but anyways... I'm not sure, that auxiliary table will address complexity issues here... I may be wrong, but it seems simpler to just create two parent entities without any *ToMany relations inside, and the one entity representing join table with one-to-one relation on these parents. In my view, add/remove of both parents and relations between them should be much easier in this regard, as well as understanding of the code. Of course, not everything is cloudless with such an approach. For instance, I'm predicting a lot of troubles with further conversion of the retrieved entities into DTO/JSON to propagate it further as a REST API response: if we had *ToMany parent-child entity, it will be converted into one JSON automatically keeping "children" field as an array of relations. But in case of separate entities, you should do extra activities to compile different entity objects into one DTO/JSON.
@@Exterminator131 You don't need to convert entities to DTOs. You can simply extract Hierarchical DTOs directly from the DB, as I explained in this article vladmihalcea.com/one-to-many-dto-projection-hibernate/ Fetching entities only to discard what you don't need and create a DTO is wasteful. If you think that avoiding the collections is easier for you, then you should not map the associations. In the end, any collection can be replaced with a query.
nice video length!
I'm glad you liked it
Great explanation Sir.
You're welcome. If you liked this episode, you are going to love my High-Performance SQL video course.
Thanks for the most of the approaches demonstration but can you please tell me something for the result set we know what would be the value that we are selecting and we keep one DTO for the resultList for the values that would be coming to us, but what if we don't know what are the values that we are selecting(like we know that the fields are part of some Entity class) but we don't know what are the values that would be requested for us like sometimes five values are requested and sometimes 10 values so what should we do then ? Obviously we cannot create a ResultDTO for the values for every combination, then please suggest how to create a DTO for the resultSet for the values that would do something like when five fields are selected we set the five values and rest of the fields we set as null ? What would be the efficient way to do this ?
You can create a different DTO for each specific use case. If you have 5 different use,cases, you create 5 DTOs. Or, you can use the Spring Data JPA interface-based projection and avoid creating the DTO classes.
What do you recommend, if there are multiple many to many relationship in the same join table?
I don't see how the same join table could ever be used to store multiple FK sets for different parent sets.
Hi @vladmihalcea , Thank you for the prompt reply. Let's say I am storing roles for a tenant and the associated user. so my join table will have user_id, role_id and tenant_id and some extra colums. My question was, can we apply the same logic as suggested in the video in this case too?
I am using the same mapping as suggested in the video, for my case as well, just wanted to know if there are better ways than this.
@@Abhishekchandel008 Your join table can have extra columns and extra associations. Check out my High-Performance Java Persistence video course for more details: vladmihalcea.teachable.com/p/high-performance-java-persistence-mach-3-online
@@Abhishekchandel008 There's always a better way. However, that requires analyzing your schema and the business requirements. Luckily, I do offer consulting if your company is interested in improving their codebase.
I'm receiving the error message 'sqlExceptionHelper - table 'post' does not exist, skipping,' along with a batch of similar logs. What could be the issue? This code runs in testcontainers. Do I need to manually adjust the debug log level or something?
When the DB schema is built, it first tries to drop the tables. If there is no such table, the DROP will not work, but the failure is skipped since it's not an issue. As long as the tests run, everything runs as expected.
Cool, so I just need to adjust the logs to debug.
thanks for sharing ur knowledge. Really usefull to understand how those things work under the hood
I'm glad you liked it and stay tuned for more
What is batch job? Can we replace the batch job "actor" With a second/multiple user such as Bob?
What happen if there are 2 READ/SELECT transactions happen at the same times?
The second transaction can be anything.
@@vladmihalcea sorry, i need to ask you. On that article, you said pessimistic/serializable does not solve Lost Update problem, could you explain it further?
@@romarioputra3775 You can find a more detailed explanation in the Transaction module of my High-Performance Java Persistence video course vladmihalcea.teachable.com/p/high-performance-java-persistence-mach-3-online
Could you please elaborate on the cases where it is better to map the Join Table in a separate JPA Entity? Thanks in advance
You can find a detailed explanation of your question in my High-Performance Java Persistence video course. Enjoy watching almost 11 hours of video lessons: vladmihalcea.teachable.com/p/high-performance-java-persistence-mach-3-online
Why not make a Post as a relation owner?
Why would I do that?
Thank you for video! I have a question, can i create DTO projection if my entity have nested collections?
Yes, of course. Check out this article for more details vladmihalcea.com/one-to-many-dto-projection-hibernate/
@@vladmihalcea thank you very much.
@@vladmihalcea If I have 5 collections in entity, and that collections have nested collections, than I want to fetch all that fields. Can you help to find answer for that? Thank you.
@@user-cr5kz9nb5d You can do it like this github.com/vladmihalcea/high-performance-java-persistence/blob/master/core/src/test/java/com/vladmihalcea/book/hpjp/hibernate/fetching/multiple/MultiLevelCollectionFetchingTest.java#L108
Hi Vlad, thanks for your video. May I have several questions as below: 1. why when the first statement "select 0,0" executed, then these 0,0 sent to i, and consecutive_sum? while the whole statements within "With" haven't finished yet? 2. IN the second statment i.e. recursive statement "select i + 1, i + 1 + consecutive_sum from consecutive_sum_number" And when i + 1, i+1 + consecutive_sum will be sent to i, and consecutive_sum again for the next iteration? In short, it doesn't look like a native recursive isn't it? cause it doesn't seem to be function call same function, so everytime when consecutive_sum is call then within this function we have select 0,0, union with something. it quite confused me. Thank you
SQL is a declarative language. You're analyzing the query definition using a procedural mindset. That's why it confused you. What you need to do is run EXPLAIN ANALYZE on the query and see exactly the stream operations done by the DB when executing the query.
@@vladmihalcea Thanks Vlad, will try to explore more. anyway subcribed to your channel to see more useful contents.
Excelent video, it was so helpful. Thanks!
You're welcome
Video sound is low. Btw good explanation.
On my latest videos, I increased the volume.
Hope you continue similar fine tuning videos, gives a lot of information to grasp
I'm glad you liked it
@@vladmihalcea Your videos are excellent, well explained with high quality image, etc. But if they all have the same title, how do I know the order? For example: Part 1, Part 2, etc? Thank you.
@@Jody-nf2bz In the description of every video, you will find information about the previous and next videos in the series. However, you can watch them in any order as each one is dedicated to a specific topic.
@@vladmihalcea Thank you.
@@Jody-nf2bz You're welcome. Enjoy watching them!
Great explanation! Thank you
Thanks and stay tuned for more
In Windows 10 is there a way to create tmpfs?
It's easier if you use Docker to run the DB on tmpfs. This works no matter what host OS you use. vladmihalcea.com/how-to-run-integration-tests-at-warp-speed-with-docker-and-tmpfs/
@@vladmihalcea Got it, another question on the android phone is there any app for me to create tmpfs or ramfs?
@@vagnerdasilva1652 For SQLite on Android?
@@vladmihalcea Is this SQLite the name of the application that you said you have in the Play Store?
@@vagnerdasilva1652 I didn't say anything about Play Store. It's unlikely that you need tmpfs for Android.
Love what you do! :) Thanks for these videos.
You're welcome
Very informative video .. Thanks a lot Vlad
Thanks and stay tuned for more
Looking forward to the series!
Prepare yourself to be amazed 🚀
Thanks!
You're welcome
You are true champion 🏆
Thanks and stay tuned for more
Thanks for the great video, as always. Could you please share what visualization tool you are using at 0:45?
The class diagrams were generated with IntelliJ IDEA. The DB table diagrams with MySQL Browser. The rest of the diagrams were generated with yEd.
As always very good Video Vlad, Thank you.
You're welcome and stay tuned for more
I find JPA Query DSL lib much much better than Criteria API, I don't know why people use Criteria API. What do you think about Query DSL Vlad ?
I use Blaze Persistence instead of Criteria API: vladmihalcea.com/blaze-persistence-jpa-criteria-queries/ QueryDSL was abandoned for many years, and only currently got some updates. For native SQL, I'd rather use jOOQ, as it's superior to QueryDSL in any way.
@@vladmihalcea It seams Blaze does not give TypeSafe queries like QueryDSL, what is other disadvantage of QueryDSL beside not being maintained actively ?
@@vaheharutyunyan966 Blaze Persistence has typed queries using the JPA Metamodel vladmihalcea.com/bulk-update-delete-blaze-persistence/ However, jOOQ is even more powerful than Blaze. You can even use it to fetch efficiently multiple one-to-many relations without a Cartesian Product: blog.jooq.org/jooq-3-15s-new-multiset-operator-will-change-how-you-think-about-sql/ It's also amazing for stored procedures too: vladmihalcea.com/jooq-facts-sql-functions-made-easy/ Plus, it offers Keyset Pagination, Recursive CTE, Pivot, Window Functions, Lateral Joins, JSON, and many more features. And it's maintained and improved constantly.
Thank you very good info
You're welcome
How can we achieve this feature in spring data jpa?
Which feature are you talking about?
@@vladmihalcea I mean one to one relationship without n+1 problem which you described in video
@@aleemkhowaja2274 The solution for that can be done with a Maven or Gradle plugin that it's independent of Spring. So, it works I the same way with Spring as it does with Java EE.
@@vladmihalcea ahh ok yaah makes sense to me thanks bro btw great explanation in video and thank you so much for response cheers 🥂 🙂
@@aleemkhowaja2274 You're welcome. If you liked this video, there's a 40% discount on the video course: vladmihalcea.teachable.com/p/high-performance-java-persistence-mach-3-online/?coupon_code=BLACKFRIDAY22 But hurry up! It expires in 2 days.
Great video! Now, I'm thinking about whole course :) please, tell me why children entity should be owning side of relation?
I'm glad you liked it. In fact, you are going to love the video course even more. As for your question, the entity that maps the FK column is the one that should own the relation because FK column values are supposed to be managed via their associated table record.
Thank you for all the information. Do you have some more information when to use which approach?
Thanks. I'm glad you liked it. You can find more information about the topic and details about when to use one strategy or the other in my High-Performance Java Persistence video course. vladmihalcea.com/courses/high-performance-java-persistence/ It features 11 hours of video lessons that you are going to love even more than this sample.
👍🏻
Thanks
Please continue 🙏😍
I will. Subscribe to get the update.
Thank you so much sir ❤️
These approaches are much better than handling Object[] data but still look kind of complicated. Why can't I just supply a random object with fields annotaded such that the framework code can figure out how to assign results to the fields. Like (annotations made up, example simplified): @MappableResult public class PostDTO { @ResultMapping(name = "id") Long id; @ResultMapping(name = "title") String title; } Hibernate already does this with entities and @Column annotations, why not use a similar thing here? Would this break some core principles of the framework?
Actually, you can do that using Blaze Persistence. persistence.blazebit.com/documentation/1.5/entity-view/manual/en_US/#basic-mappings It's OSS and extremely powerful. It's like a JPA plugin that provides additional features.
@@vladmihalcea Oh that's good to know, I'll try this out :) Thanks
@@jkickic It's a really useful framework. I'm using it to write advanced Criteria queries that are way more readable than the default Criteria API. vladmihalcea.com/blaze-persistence-jpa-criteria-queries/ And you can also use it for Keyset Pagination with Spring Data JPA: vladmihalcea.com/keyset-pagination-spring/
Very Informative
Thanks and stay tuned for more
Awesome video and direct explanation, thanks from Brazil
Thanks. I'm glad you liked it. This is part of my High-Performace SQL video course, so if you liked it, you are going to love the entire course. vladmihalcea.com/courses/high-performance-sql/
why do i need to have a one to one relationship? I mean i can wrap the details or include it in the post table
That's a very good question that I frequently get during my training. The @OneToOne relationship basically maps the one-to-one table relationship that was designed 40 years ago and which serves plenty of use cases, like the following ones: - if you have a JSON column that's large, you might not want to fit it on the same page as the original record as that could create page splits, increase the volume of data that gets synced to the disk when the pages get dirty - if you have columns that have different change frequencies, you can split them by write access patterns so that you could have the columns that frequently change in a separate table whose pages get synced often, but they leave the other table pages to reside in the Buffer Pool - to implement the JOINED table inheritance strategy - to split a large table into multiple ones to increase write scalability as UPDATEs and DELETEs take locks at record level in relational databases, and once you change a single column, the entire record gets locked until you commit or roll back. But by splitting the original table into several tables, you can increase the write throughput. - to reduce the optimistic locking conflicts as you have multiple version columns in multiple tables. If you only have a single table, then any column change will cause the other concurrent transactions that also want to change the same record to abort after the first transaction has bumped the version up.
Today I have heard about you from my colleague, and I fell in love with your articles and now I am very glad to see you here. Thanks in advance))
Thanks and stay tuned for more
Awesome content as always, keep up the good work!
Thanks, Piotr. Stay tuned for more!
awesomeeeeee
Thanks and stay tuned for more