JPA/Hibernate Fundamentals 2023 - Lesson 4 - Primary keys
Vložit
- čas přidán 8. 09. 2024
- Buy me a coffee ☕👉 buymeacoffee.c...
In this stream, we discuss the JPA specification and learn to implement the persistence layer of a Java app using a JPA implementation such as Hibernate.
Laur your way of explanation is incredible, please make a cource on microservices
I wish I would get that much deep knowledge at my initial stage of my carrier
+1
Amazing tutorial, Thank you
GitHub: github.com/lspil/youtubechannel/tree/master/jpa_2023_c4_e1
Hey, thanks for your videos, ur the best!!!
Can u record video about creating OAuth2 authorization server with dynamic RegisteredClient and JPA ? (When user can create a clients for authentication).
Theme with OAuth2 in spring so hard and raw, we need more content about that!!!
Thank you so much for this course again. I like to watch and read everything you do, you are just great. I just want to ask you a question, I know that I am currently on the 4th video but do you refer to cache mechanism in next videos? If you don't, is there any chance you recommend a source to learn cache mechanism on hibernate or a specific technology widely used in applications?
Hmm.. No sure I know a specific book or video solely on caches :(
Hello from India. Sir, your videos are outstanding. I am a university professor and i teach students by simply going through your videos. I have read the first chapter of your book "Spring Start Here". Is there a way i can get a copy of that book? It will be really helpful for my subject. Thank you..
Hello. I think you can find it online the PDF version. I don't think the paper version is available in stores in India.
Thanks laur, I felt composite keys little bit hard to get in JPA. But you put it simple. :)
Glad to hear :)
Thanks, as always :). Could you please make a video on Java Security/cryptography, which you use at 13:36, because I really don't understand what you did from that point onwards.
Very good lesson, congratulations for such good content 😃. could you make videos about clean code in Java?
Sure. Thanks for your recommendation.
nice turtorial, I've also seen annotation SequenceGenerator above entity class, is that another way of using generator for primary key?
If I'm not wrong that is Hibernate specific and not inherited from JPA.
looked it up on the JPA documentation, as I understand it seems to be used when you want to use a sequence already declared on the db level.
@@holdenkarlhain96 I'm not sure I understand. All sequences are already declared at the DB level when you want to use them from a Java app. That is regardless of whether you use not a JPA implementation.
yeah I guess I meant when you create a sequence in a db script and then want to use that sequence by name for a primary key on your java entity.
Im still learning JPA and definetly could have understood it incorrectly reading the documentation though.
Anyhow thanks for this series you explain things very well and its been really helping me grasp these conspets. As Im just finishing my bachelors degree in cs and wanting to start working as a junior dev.
Hello Laur! I was able to create a composite key without an external IdClass. Just placed two ID annotations above the fields. Why do you need to create an external class?
I found only one advantage of the IdClass: you can put the Id annotation on only one field in the entity, but the key will still be composite, as described in IdClass.
Good question. I will check that. Maybe something changed in the last JPA version. I don't know. Usually having a class for the composite primary key was mandatory.
Thank you! I just checked the latest JPA 3.1 specification: "The EmbeddedId or IdClass annotation is used to denote a composite primary key." Only two options, as you described.
Perhaps in my case this is some undocumented feature. I'm using the latest hibernate-core 6.3.1.Final and the latest Postgres.
@@Boyarsskiy Wither that or it can happen sometimes some frameworks work differently. For example in Hibernate it might work but not in others. Best is if you stick to the specification in such a case.
Completely agree
I have not seen yet the next videos from this playlist, but please Laur, put the sponge or how it is called, on the microphone to make your voice smoother and to cancel distortions. It's because you keep the microphone too close to the mouth, and it's hard to listen to you.
question if this jpa we will connect with real oracle db server which has more pakcets and more data tables with ddl-auto create. will it truncate whole schema with all
table and packets ?
Hello. I am not sure this is a question or an observation. As I mentioned in the videos, ddl-create auto should only be used in examples. Never use it in real live apps. In real-world scenarios you can use Flyway or Liquibase to manage the scripts.