Spring Data JPA Relationships - ManyToMany, ManyToOne & OneToMany

  Рет қаралды 64,891

Bouali Ali

Bouali Ali

Күн бұрын

Пікірлер: 144
@BoualiAli
@BoualiAli Жыл бұрын
Join the Micro Services course waiting list and get and get an exclusive *EARLY-BIRD discount* aliboucoding.ck.page/d0f9317e13
@DiplomasizKodcu
@DiplomasizKodcu Жыл бұрын
How did I not seeing your videos before? Did you know your the only one who explained entire stuff? I will watch your entire list and share your account for those who need. Thanks a lot for great content.
@BoualiAli
@BoualiAli 9 ай бұрын
Glad you liked it!
@santhosha-z5x
@santhosha-z5x 2 ай бұрын
thank you so much you saved my interview time by minimizing all extra's i recommend this videos to others who didn't understand relationships properly.
@landry_john
@landry_john Жыл бұрын
Thank you for that great lesson about Spring Data JPA Relationships.
@BoualiAli
@BoualiAli Жыл бұрын
Glad it was helpful!
@taiwoobadare
@taiwoobadare Жыл бұрын
Very very good explanation, well simplified, great job!
@BoualiAli
@BoualiAli Жыл бұрын
Glad you enjoyed it!
@GuilhermeMirandaZelinschideArr
@GuilhermeMirandaZelinschideArr 9 ай бұрын
the only video that made me understand the concept great work
@BoualiAli
@BoualiAli 9 ай бұрын
glad to hear that!
@hazel-BKJ
@hazel-BKJ 10 ай бұрын
Your video is beyond reproach, from theoretical concepts to practical application. Thank you very much for the content, Mr Ali, which is full of pedagogy and enables me to make progress as a beginner with the spring boot framework.
@BoualiAli
@BoualiAli 8 ай бұрын
You are most welcome
@ines_edim
@ines_edim Жыл бұрын
1. You have good well drawn out diagrams and visualizations, it's very helpful 2. Your explanations shows that you have solid fundamentals [Coding + SQL] 3. You gave Practical and Relatable examples. 4. Kudos to you. I am coming from a C++ background, and I appreciate the attention to details in this video. I'll be sure to watch the playlist. You've got 1 new subscriber here.
@BoualiAli
@BoualiAli Жыл бұрын
Great and detailed feedback. Happy you liked it!
@shenanvindinu
@shenanvindinu 2 ай бұрын
Much love ❤❤
@natanduarte5273
@natanduarte5273 5 ай бұрын
UR AN LEGEND i sspent more than 4 hors trying to get this right, and the u showed up THX
@ShermukhammadKarimov
@ShermukhammadKarimov 6 ай бұрын
thanks for this amazing tutorial
@parmodprajapati
@parmodprajapati 2 ай бұрын
Hi Great, Could you please make videos on Spring Security like this one.?
@BoualiAli
@BoualiAli 2 ай бұрын
Already did. Check the videos
@sithumsathsara7966
@sithumsathsara7966 4 ай бұрын
Good😀
@khaledoueslati66
@khaledoueslati66 8 ай бұрын
Very Nice video keep the great work up 🙌🙌
@BoualiAli
@BoualiAli 8 ай бұрын
Thank you so much 😁
@kishorem5101
@kishorem5101 3 ай бұрын
Why I got sleepy when I'm heard your voice 💤😴😴
@okeowoaderemi
@okeowoaderemi Жыл бұрын
Amazing Tutorial I just joined your discord
@BoualiAli
@BoualiAli 9 ай бұрын
Awesome thank you!
@satyamsc
@satyamsc 2 жыл бұрын
Nice.. Easy to understand. !!!.
@BoualiAli
@BoualiAli 2 жыл бұрын
Happy to know your feedback 😁
@wantedlepota9960
@wantedlepota9960 6 ай бұрын
I would have loved to see how you test this, how would the JSON input would look like representing those entity relationships
@markotomic4368
@markotomic4368 7 ай бұрын
Thank you Ali for this wonderfull explanation!
@BoualiAli
@BoualiAli 7 ай бұрын
You are very welcome
@mohamedhediaissi598
@mohamedhediaissi598 7 ай бұрын
Thank you so much for this video !! It really helped me a lot !!
@mamadoumorobah1777
@mamadoumorobah1777 2 жыл бұрын
Merci beaucoup pour le partage de savoir
@BoualiAli
@BoualiAli 2 жыл бұрын
My pleasure Don’t forget to share the video 😄
@genusleemapedze1177
@genusleemapedze1177 Жыл бұрын
Would be glad if you can create maybe a single end to end application with spring security included in the app and also learning more about the DTOs e.g a blog app with several roless
@BoualiAli
@BoualiAli Жыл бұрын
I will consider this idea.
@solowolf5304
@solowolf5304 Жыл бұрын
@@BoualiAli yes plz do consider this
@inihood
@inihood Жыл бұрын
@@BoualiAli Please do it
@BoualiAli
@BoualiAli Жыл бұрын
@@inihood i already published a spring security video
@Ramziddin_Rustamov
@Ramziddin_Rustamov 2 ай бұрын
27:15 visualization:) never mind
@sphesihlemanuel2933
@sphesihlemanuel2933 Жыл бұрын
Great video, this was very helpful
@BoualiAli
@BoualiAli Жыл бұрын
Glad it was helpful!
@messironaldo1708
@messironaldo1708 2 жыл бұрын
That was soo helpful. Thank you!
@BoualiAli
@BoualiAli 2 жыл бұрын
My pleasure
@Supremevillacom-house
@Supremevillacom-house 4 ай бұрын
🎉🎉 thanks 👍👍😊
@BoualiAli
@BoualiAli 4 ай бұрын
Welcome 😊
@trinhlong2665
@trinhlong2665 Жыл бұрын
Thank you Bouali Ali. Would be glad if you can complete this project by creating some Rest Controller class. I hope to see you have more videos about this course.
@BoualiAli
@BoualiAli Жыл бұрын
I already have videos about that. Check the playlist Spring workshops
@abhinavjain8613
@abhinavjain8613 Жыл бұрын
Please add link
@aboubacardiaby3700
@aboubacardiaby3700 Жыл бұрын
Salut Mr Bouali j'ai une question pertinante pour vous. le faite de créer une liste lorsqu'on a une annotation @OneToMany dans une classe permet de faire quoi concrètement
@marouenghozzi4778
@marouenghozzi4778 5 ай бұрын
How can we decide who’s the owner of the relationship between two entities ?
@mursalin3698
@mursalin3698 2 жыл бұрын
well done
@BoualiAli
@BoualiAli 2 жыл бұрын
Thanks
@supun_sandaruwan
@supun_sandaruwan Жыл бұрын
awesome video 🔥 Thank you
@BoualiAli
@BoualiAli Жыл бұрын
Glad you liked it!
@amenimensi8817
@amenimensi8817 8 ай бұрын
good job
@BoualiAli
@BoualiAli 8 ай бұрын
Thanks
@mohamedoueslati462
@mohamedoueslati462 Жыл бұрын
Good job , Thanks Ali :)
@BoualiAli
@BoualiAli Жыл бұрын
Always welcome
@AshishRohillax
@AshishRohillax Жыл бұрын
Thanks a lot, really helpful
@BoualiAli
@BoualiAli Жыл бұрын
Happy to know that 🔥
@apexyu164
@apexyu164 8 ай бұрын
in all this relationship, which one will auto ipdate the table if one insert happen
@elliotsaii7904
@elliotsaii7904 2 жыл бұрын
that's was awesome video
@BoualiAli
@BoualiAli 2 жыл бұрын
Thank youu
@nourhenjridi7963
@nourhenjridi7963 10 ай бұрын
SVP comment vous affichez le diagramme de classe représentant les entités dans votre projet Spring Boot avec une base de données ?
@kushagraahire1871
@kushagraahire1871 5 ай бұрын
thanks
@solowolf5304
@solowolf5304 Жыл бұрын
New viewer here. I hope 10K subscribers would be a good motivation for you to bring more good content like this !!
@BoualiAli
@BoualiAli Жыл бұрын
Absolutely
@ernanibatista1806
@ernanibatista1806 10 ай бұрын
Tks but when we insert in the table employee , adress_id retuning null
@mohamedwiem4965
@mohamedwiem4965 Жыл бұрын
Amazing content as well, just I wanna ask if the integration of database and diagrams you use exists in STS or intellij community edition or just in intellij ultimate !
@BoualiAli
@BoualiAli Жыл бұрын
Happy you liked it. Not sure about sts, but for Intellij it is just ultimate version
@angsh
@angsh Жыл бұрын
Gold!
@BoualiAli
@BoualiAli Жыл бұрын
Thank you
@samirbenaziz520
@samirbenaziz520 7 ай бұрын
salem khouya ya3tik sa7a 3al vidéo juste question : OneToMany wel ManyToOne dima relation binéthom unidirectionnelle ???
@AntonioCabralNumberOne
@AntonioCabralNumberOne 10 ай бұрын
Thank you once again for your dedication with your beautifully explained videos! I have one question about ManyToMany relationships: If you need an extra column in the relationship table between (in your case) the Employee and the Mission tables, let's say e.g. a "created_at" column, how would you add it, set it and get it? Thank you in advance!
@RandomSrr751
@RandomSrr751 8 ай бұрын
Hi there! So, I'm about a month late, and I'm also just getting started with coding, but I solved this situation last week. In ManyToMany relationships, the intermediate table is generated automatically, which means you can't easily add more attributes without modifying the relationship itself. The only way I found to resolve this involves actually not using ManyToMany but setting up two OneToMany relationships between employees/missions on the "One" side, linking them to a third entity that contains both IDs along with any extra attributes. Using an example, this would be represented by the EmployeeMission class, which includes employeeId, missionId, and createdAt attributes. As Ali shows here, for OneToMany relationships, it's important to specify the "mappedBy" annotation, and I also found it helpful to specify the fetch type. I hope my explanation is clear and helpful. Have a great day!
@parmodprajapati
@parmodprajapati 9 ай бұрын
Hi, When we go for Unidirectional mapping and which is best according to requirement? We can also set the employee id to the address table so why should we address id set to the employee table.
@BoualiAli
@BoualiAli 8 ай бұрын
It depends on the logic and needs for your application
@fernandoereno5597
@fernandoereno5597 2 жыл бұрын
Thank you!!!
@BoualiAli
@BoualiAli 2 жыл бұрын
My pleasure
@wassimsakri8654
@wassimsakri8654 Жыл бұрын
thank you
@BoualiAli
@BoualiAli Жыл бұрын
My pleasure
@MFM88832
@MFM88832 8 ай бұрын
Good video but it would be more informative if you showed Crow's foot notation in your visaulisation diagram.
@BoualiAli
@BoualiAli 8 ай бұрын
Ok next time
@chokribenrejeb8115
@chokribenrejeb8115 2 жыл бұрын
Thank you,. how we can achieve ManyToMany relationship whene the join Table should have some data.
@BoualiAli
@BoualiAli 2 жыл бұрын
You need to create an extra entity that will hold the relation and the extra fields as well
@kamilleskamilless8113
@kamilleskamilless8113 2 жыл бұрын
@@BoualiAli could you please create video about that?
@BoualiAli
@BoualiAli 2 жыл бұрын
@@kamilleskamilless8113 about what exaclty?
@emonadriane5525
@emonadriane5525 Жыл бұрын
Thanks really @Bouli ..can you please make a video/tutorial on making an e-commerce API including uploading product image plus attaching the different prices. Or maybe a destinations API
@BoualiAli
@BoualiAli Жыл бұрын
I really would like to, bit this gonna take so much time. I hope I can do it one day
@emonadriane5525
@emonadriane5525 Жыл бұрын
​@@BoualiAli Really thanks. Stay blessed!
@mohamedwiem4965
@mohamedwiem4965 Жыл бұрын
thank u ! employee_mission was automatically generated in our database , should we create employee_mission class in our entity package or is not necessary ?
@BoualiAli
@BoualiAli Жыл бұрын
if you don't have any extra fields, you don't need to
@apexyu164
@apexyu164 8 ай бұрын
How to add database to spring in right panel?
@dorrakadri1474
@dorrakadri1474 2 жыл бұрын
can u explain the cascade types
@BoualiAli
@BoualiAli 2 жыл бұрын
Will note that for the next video
@adelteyeb2427
@adelteyeb2427 Жыл бұрын
Thinks can you make a video about MVC architecture
@BoualiAli
@BoualiAli Жыл бұрын
Happy you liked it! Soon
@mugenzideodate5733
@mugenzideodate5733 Жыл бұрын
Can you help us, full project by using spring boot multipe tables like 3 tables from database on back end and fetch data to front-end in single table?
@BoualiAli
@BoualiAli Жыл бұрын
aliboucoding.com/courses
@zqgAFf
@zqgAFf Жыл бұрын
Thank you so much for such a nice clean video , However I made the simlar entities with one to one bidirectional , when I check the database , it does have each other id as foriein key ,however my app won't start again , but if add something like mapped by employee and add cascade = cascadeType.All , then there won't be two foreign key , there is only one address_id ,but the other foreign key won't appear from the other table ....I am confused
@BoualiAli
@BoualiAli Жыл бұрын
Why your app is not starting after adding one to one? Can you provide some logs in the discord server (screenshots) to make easier to understand
@zqgAFf
@zqgAFf Жыл бұрын
@@BoualiAli Yeah I noticed on one to one bidirectional it is better not to provide mapped by on one entity otherwise,otherwise there’s only one foreign key like unidirectional
@bagzhansadvakassov1093
@bagzhansadvakassov1093 5 ай бұрын
You haven't left the source code?
@thanhninh8677
@thanhninh8677 Жыл бұрын
Can you give me the link of the next video , i can't find it
@BoualiAli
@BoualiAli Жыл бұрын
Spring Data JPA | Hibernate kzbin.info/aero/PL41m5U3u3wwkS8BU0fIeRQwY3hK4VlFlX
@haobui8913
@haobui8913 8 ай бұрын
Can anyone tell me what is the function of MappedBy????
@fumano2679
@fumano2679 Жыл бұрын
I have a problem when inserting an entry with the many-to-one relationship. Lets say i have created a department with the id of 1 in my database and now want to create a employee. I a few cases to do this. 1. By placing the department_id = 1 int the json, 2. by placing the department = 1 in the json, 3. by placing the department equal to the department json from my db entry, 4. by getting the department object from an api call and then employee.setDepartment(department). None worked. Is it not possible to create an Employee by referencing the department id?
@BoualiAli
@BoualiAli Жыл бұрын
when creating an employee you need to set the department object and pass the department is Here is an example Department dep = new Department() dep.setId(departmentId) // the one you get in your request / object / param (depends how you get it) Employee emp = new Employee() emp.setField() emp.set....() emp.setDepartment(dep) repository.save(emp)
@kevinameda2711
@kevinameda2711 Жыл бұрын
Hi @Bouli for the great tutorials. Could you please make a video about spring security with oauth will appreciate thank you in advance
@BoualiAli
@BoualiAli Жыл бұрын
Already have one about spring security. Check it in the same playlist
@kevinameda2711
@kevinameda2711 Жыл бұрын
@@BoualiAli I did and it is an absolute honour to even talk to you. Where can I reach u out to talk further?
@BoualiAli
@BoualiAli Жыл бұрын
@@kevinameda2711 the honor is mine You can reach me on our discord server
@amineessaoud1493
@amineessaoud1493 9 ай бұрын
Does OneToMany & OneToMany exist in Spring Boot ?
@BoualiAli
@BoualiAli 9 ай бұрын
yes
@Sumeshkumarback
@Sumeshkumarback 7 ай бұрын
Perform CRUD operation in above relationship
@orestdymarchuk2910
@orestdymarchuk2910 Жыл бұрын
When you create an Entity, you created an Integer field with the "id" annotation. Can you please clarify why this field should be an Object type and not a primitive one?
@BoualiAli
@BoualiAli Жыл бұрын
Object by default is null Premitive like int by default 0 You null on the id to help hibernate well manage the entities. Checkout my new course about spring data jpa and you will understand all this details and master this topic aliboucoding.com/courses
@sureshattimarad1796
@sureshattimarad1796 Жыл бұрын
Bacause we use ArrayList type field to hold MANY objects, Since ArrayList implements List interface that SUPPORTS only OBJECT TYPE not the primitive type
@jopadjr
@jopadjr 2 жыл бұрын
46th...Thanks
@BoualiAli
@BoualiAli 2 жыл бұрын
Welcome
@osasereuhunmwangho5293
@osasereuhunmwangho5293 Жыл бұрын
Thank you Bouali Ali. This is very concise and really gainful for me. For the one-to-one relationship, in what context is the relationship uni-directional or bi-directional?. Thank You
@BoualiAli
@BoualiAli Жыл бұрын
Unidirectional Relationship: This means that one entity has knowledge of the other, but not vice versa. In other words, if you have two entities, say EntityA and EntityB, and if EntityA has a reference to EntityB (but EntityB does not have a reference to EntityA), then it's a unidirectional relationship. Unidirectional relationships are simpler and less complex, and are suitable when there is no need for the referenced entity (EntityB in our example) to know about the entity that is referencing it (EntityA). For instance, if you have a User entity and a Profile entity, and each User has one Profile, but a Profile does not need to know which User it belongs to, you can model this as a unidirectional relationship from User to Profile. Bidirectional Relationship: This is when both entities are aware of each other - EntityA has a reference to EntityB, and EntityB also has a reference to EntityA. This kind of relationship is a bit more complex due to the need to keep both sides of the relationship in sync. Bidirectional relationships can be useful when there is a need for both entities to be aware of each other. For example, if you have a Customer entity and a BankAccount entity, and each Customer has one BankAccount, but a BankAccount also needs to know which Customer it belongs to, then you would model this as a bidirectional relationship.
@plowman5260
@plowman5260 9 ай бұрын
Thank you for your help
@BoualiAli
@BoualiAli 9 ай бұрын
Thank you too!
@arslanoulhaci9965
@arslanoulhaci9965 9 ай бұрын
VIZU ALI ZATION visualization
@Razes9ooo474lO4
@Razes9ooo474lO4 8 ай бұрын
employee and department uni directional or bi-directional , department table doesnt have any fk of employee
@moriahnjsahkhar8764
@moriahnjsahkhar8764 5 ай бұрын
How do i handle circular reference error in onetomany and manytoone.. ive tried @jsonmanaged and @jsonbackreference .. it kinda works but not fully.. i still get the stackoverflow error in the frontend which is thymleaf and also when i use toString method
@stevegatspaul
@stevegatspaul 2 жыл бұрын
Hey, Amazing content as always, but I have a question about how to use this in "@Repository public interface EmployeeDao extends JpaRepository", for example : findByEmployeeId and get: Employee Info and his address and his Mission and his Department.
@BoualiAli
@BoualiAli 2 жыл бұрын
Hi, can explain your question? I didn’t understand
@stevegatspaul
@stevegatspaul 2 жыл бұрын
@@BoualiAli how to use join query in spring data jpa, use Employee_Id and get: Employee Info and his address and his Mission and his Department. thank you in advance for your reply. 😀
@imedhr1814
@imedhr1814 2 жыл бұрын
thanks but you did not explain the difference between unidirectional and bidirectional in @OneToMany @ManyToOne !!
@BoualiAli
@BoualiAli 2 жыл бұрын
It was already explained in the beginning of the video
@KlanBr1
@KlanBr1 Жыл бұрын
i am doing this tutorial with pgAdmin 4, and the relation ONETOONE, it's looks like ONETOMANY on my DER
@BoualiAli
@BoualiAli Жыл бұрын
How is that possible? Can you share some screeshots and code snippets on the discord server?
@miloudseo7883
@miloudseo7883 2 жыл бұрын
Je crois au niveau entity employee tu doid crée comme ceci:@ManyToOne(mapping="employee") Private collection departmant;
@BoualiAli
@BoualiAli 2 жыл бұрын
Pourquoi?
@miloudseo7883
@miloudseo7883 2 жыл бұрын
@@BoualiAli suivant la cardinalite que vous mentionné dans votre diagramme de class.
@BoualiAli
@BoualiAli 2 жыл бұрын
@@miloudseo7883 peux tu expliquer plus?
@miloudseo7883
@miloudseo7883 2 жыл бұрын
@@BoualiAli clé étranger de la table employee doit etre dans la table départemant car un employee appartient à plusieurs départemant, et chaque départemant ayant une seul employee(ma raisonnement suivant la cardinalité que vous avez mentionné, en uml en raisonne comme ca)
@miloudseo7883
@miloudseo7883 2 жыл бұрын
@@BoualiAli je crois tu dois changer la cardinalité entre table employee(*) et departemant(*) to ManyToMany
Spring Data JPA -Criteria Queries - The Full Guide
30:07
Bouali Ali
Рет қаралды 48 М.
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Chain Game Strong ⛓️
00:21
Anwar Jibawi
Рет қаралды 41 МЛН
JAVA DTO Pattern Tutorial | Simplify Your Code
19:12
Amigoscode
Рет қаралды 221 М.
Spring Data JPA - One to One mapping in spring boot | MySQL
1:20:27
Selenium Express
Рет қаралды 6 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 224 М.
#12 Hibernate Tutorial | Mapping Relations Theory
13:14
Telusko
Рет қаралды 314 М.
Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF
28:34
Decomplexify
Рет қаралды 2,2 МЛН