I've been stuck for hours not being able to create the bidirectional relationship, it was always caught from only the one end and I was going mad as to why... and it turned out it is the thing you mention at 6:28, because I was using @Data in both places. Thank you so much man, appreciate the tutorial!
@rslakshmilifestyle Жыл бұрын
Thank you so much ur comment helped me to fix my issue. 😊
@antoniyhristov Жыл бұрын
@@rslakshmilifestyle glad it helped 🙏
@MartinGago3 ай бұрын
i was in the same situation as you, i thank you so much for this comment!
@antoniyhristov3 ай бұрын
@@MartinGago no worries, I am happy that I was able to help!
@yadnyeshborse52293 ай бұрын
Thanks For you comment , It help me solve my issue.
@pranaypaul63616 ай бұрын
Excellent video in terms of keeping it simple throughout focussing on the core basic of many to many!! One of the best out there.Thank you.
@alexgutjahr2 жыл бұрын
Great tutorial! Many-to-many relationships are so common in most applications. Yet I often see people struggle with setting up the relationships in the entities - they assume there has to be ONE right way of doing it, not realizing that EACH entity can own the relationship.
@Javatechie2 жыл бұрын
Agree with you
@florjandyshniku6464 Жыл бұрын
@@Javatechie Great video! But if you add another student with same courses will duplicate courses. Can you solve this problem?
@g.ariywt10 ай бұрын
Thank you for helping me understand how to use JPA and Many-to-Many relationships clearly..
@musanzawanga20832 жыл бұрын
This tutorial is a successful in explaining explain ManyToMany Relationships in Java! ✔️You made it easy to follow! ✔️Thanks alot Java Techie 💙
@roseodhiambo703 Жыл бұрын
I agree with you 💯.
@georgikyshenko4380 Жыл бұрын
Exactly what i needed. Great job. Thanks !
@thimothipalipaka852 Жыл бұрын
Hii in my project I am facing one problem, user having usercart that usercart contains products , if i add product it mapped to cart of a particular user , if add another product for same user cart it overrides the previous one how to overcome this situation .
@bluex2178 ай бұрын
Thank you! I have question for 33:46: basically I'm confused that you used FetchType LAZY but yet findById method is still populating the list of courses eagerly. I have the same behavior, but I question why
@supun_sandaruwan11 ай бұрын
Great Tutorial, Thank you sir♥
@PradeepKumar-sx6ms2 жыл бұрын
In many to many directional, there are challenges in add & delete please discuss on that
@sandeeps109310 ай бұрын
Its really a good aproach , Thanks Techie
@rakshitmandilwar2817 Жыл бұрын
Java techie please help me I am getting error 415 in postman while inserting the payload.....it says the message type is not supported I tried using header as content type application json yet it doesn't work
@Javatechie Жыл бұрын
Are you trying with http post method from postman
@rakshitmandilwar2817 Жыл бұрын
@@Javatechie yes sir I am using http post method on postman for sending the data, I tried various things like using Json ignore , adding application/json in content type yet it gives error 415 and in console it gives deserialization error
@GustavoHenri7775 ай бұрын
Thank you for the video.
@shubhamtopare97202 жыл бұрын
Thanks for the informative video, one request - if you give quick summary at the end of the video i.e. what we did from start to end with the code, it will be very easy to remember the things.
@Javatechie2 жыл бұрын
Good suggestion Subham . going forward will do same
@shubhamtopare97202 жыл бұрын
@@Javatechie Thank you.
@SumanMondal-gv8bi4 ай бұрын
Thanks you so much. I am also facing stack overflow due to @Data annotation . I didn't know that. Thank You sir.
@hkkabir2024 Жыл бұрын
good presentation but you should give all type of operations from both sides
@lovetyagi52662 жыл бұрын
when u fire find all couse student not include but we have bidrectional mapping ? so whats is the point to use @JsonBackRefrence Any Other Solution
@rekhapandit2797 Жыл бұрын
Thank u so much....its very helpful vedio....to understand many to many relationships.....please bring more vedios like as....also request bring the vedio on online shopping in springboot with react js...
@alparslancavdar2292 Жыл бұрын
Excellence work.thx a lot
@sumithulsurkar24362 жыл бұрын
Thanks for sharing the valuable knowledge, but I request you to please use mice as audio of your videos is very less. Also it will be so great help if you explain few of the concepts. I mean, why we are doing this way like.
@Javatechie2 жыл бұрын
Hi Sumit i didn't get you. Is my voice is very loud 📢 or less in video?
@lemrabottabdelaziz43572 жыл бұрын
Amazing as always !
@roseodhiambo703 Жыл бұрын
Thank you 🙌🙌sir.Then I have one question am confuse.the annotations @JsonManagedReference and this called MapStruct/Mapper .They do the same thing or ? am confused please help.Thank you
@mutturajdeval48412 жыл бұрын
Great explanation 🥰🥰
@lovetyagi52662 жыл бұрын
@JSONBACKREFEENCE create problem because at a time of serialization jsonback refrence data not came in api
@Javatechie2 жыл бұрын
It shouldn't give any issue can you please share error
@kshitijbansal36722 жыл бұрын
you are right, we cannot use @JSONBACKREFEENCE with collections, need to use @JsonIdentityInfo
@Nikhil9111911 ай бұрын
@@kshitijbansal3672 thanks bro
@fsdinterviewguide2 жыл бұрын
Useful video, thank you
@stefanoiacobelli27535 ай бұрын
My Hero!
@ANANDKUMAR-0807 Жыл бұрын
Hi Basant, I have one small Doubt. In this Example fetch type is Lazy but while fetching student details, Course Details is getting Populated. I am getting Confused. Can you Please Clarify this. Thanks
@marianojm5675 Жыл бұрын
Hello, thanks for the video, but when I do that it gives me a LAZY error, I switch to EAGER and it gives me a serialization error. Why does that happen? Thank you
@Javatechie Жыл бұрын
I have shared GitHub source code in video description please compare with your code and fix
@bunny96 Жыл бұрын
@@Javatechie , yes, you used spring.jpa.open-in-view (by default) and because of that, you didn't get a LazyInitializationException. This is an anti-pattern, btw
@omit_krish Жыл бұрын
Sir here in interface we had created findByName+(Containing) but i don't know the purpose of containing key could you please let me know...
@Javatechie Жыл бұрын
Do you know CONTAIN OR LIKE operator in SQL? CONTAINS is a predicate used in the WHERE clause of a Transact-SQL SELECT statement to perform SQL Server full-text search on full-text indexed columns containing character-based data types.
@omit_krish Жыл бұрын
@@Javatechie got it sir thanks a bunch
@kotikobillionaire2812 жыл бұрын
I have picked up the final version from repository, and run the code as is - without any modifications. It is not working. I am getting this error when trying to add Student: Failed to evaluate Jackson deserialization for type [[simple type, class com.javatechie.entity.Student]]: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot handle managed/back reference 'defaultReference': back reference type (`java.util.Set`) not compatible with managed type (com.javatechie.entity.Student). What could be the issue?
@mitu-k4b Жыл бұрын
Its bcz of using @JsonManagedReference and @JsonBackReference.... Did u get the solution?
@6nigam2 жыл бұрын
Could make a video on jersy rest integration with swagger ui with spring boot sir.
@lightd1404 Жыл бұрын
I got issues like this: when i insert new value in the table student_course_table its not update .It is just update data on table course_tbl and student_tbl. Can u help me =(((
@alelasgrutas2 жыл бұрын
thanks ! excellent
@YtSeshomaru Жыл бұрын
Maybe I'm wrong, but it seems to be bad. There's no many to many relationship if CRUD is controlled by Student entity, because there's not going to occur the same course for another student. If you delete a student, then all Courses that this Student owns will be deleted from Course entity too
@ChandlerBing112 жыл бұрын
Such a quite nice content as always. Thank you, Java Techie
@dhanshyamkamath84932 жыл бұрын
Good video.
@omit_krish Жыл бұрын
Sir once hit the get button i got response only student elements I'm unable to see course elements but course elements stored in course database table pls let me know.. 😊
@Javatechie Жыл бұрын
What is the FetchType you have set , make it EAGER
@omit_krish Жыл бұрын
@@Javatechie lazy sir
@omit_krish Жыл бұрын
@@Javatechie sir after changed also getting same error only able to see student elements..
@omit_krish Жыл бұрын
@@Javatechie as well posting elements while getting error like unsupported media type but i had added only json media type
@Javatechie Жыл бұрын
Please check the code that I have shared and try to find out the difference
@pranabkumarnath38182 жыл бұрын
I have downloaded your project from github and pasted your payloads but I am getting unsupported media type error in postman . I tried writing manually also, bt same error i got. I am using sts ide, is there any problem with that?
@pranabkumarnath38182 жыл бұрын
I think i should learn more about serialisation and deserialisation 😂😂😂. I used @JsonIgnore and it worked.
@beytullahyayla7401 Жыл бұрын
@@pranabkumarnath3818 Heyo, where did u use JsonIgnore
@sharadkumar6658 Жыл бұрын
Nice sir It works.
@ustemdogge49762 жыл бұрын
Hello, this tutorial is really good, i like it so much. But i have one question, how can i include some additional field in student-course table, for example to track the head of the group of students? Is there the way i can do this only with these annotations or i have to create entity for this?
@Javatechie2 жыл бұрын
No it's not possible to achieve using annotation you need to create your own entity to maintain this
@rakibulhasan19232 жыл бұрын
when I used The @JsonManagedReference and @JsonBackReference annotations the data fetching success but did not save data. but without those annotations data saving success but not fetch data
@Javatechie2 жыл бұрын
With this annotations Post is not working? Do you mean the same
@learningjavawithme9152 жыл бұрын
@@Javatechie yes
@beytullahyayla7401 Жыл бұрын
Hi, did you find the answer
@Javatechie Жыл бұрын
Are you also facing same issue?
@beytullahyayla5971 Жыл бұрын
@@Javatechie yes
@anuraglakhara51672 жыл бұрын
Hello sir If we want to map previously saved courses to a new student then what should we do?
@Javatechie2 жыл бұрын
Yes simply pass student with list of existing courses
@maheshmali7015 Жыл бұрын
@@Javatechie Hello Basant Sir.. When I am trying to create new student record with existing course details, duplicate records are inserting in course table..
@Javatechie Жыл бұрын
Do save and update instead of direct doing save
@yacinedrissi88112 жыл бұрын
Hi thank you for your effort please could you do a crud operation with many to many thank you
@shubhamkale5003 Жыл бұрын
How can I add same course for 2 different students?
@sudheerkumar-tp1mg2 жыл бұрын
Hi Basant sir, I have one interview question, how do we maintain @transactions between 2 micro services with 2 different dbs.
@sudheerkumar-tp1mg2 жыл бұрын
One interviewer asked me, please suggest any video in our channel
@Javatechie2 жыл бұрын
You need to use saga design patterns
@sudheerkumar-tp1mg2 жыл бұрын
Thank you very much basant sir, for your quick reply.
@Javatechie2 жыл бұрын
Please check the tutorial below 👇 1. kzbin.info/www/bejne/l4DIn2RjpbZ_kMk 2. kzbin.info/www/bejne/bICYmn1thbCIntU
@samantr2 жыл бұрын
any enterprise application will have atleast 15-20 entities and relationships between them. In such cases what is best design - defining the relationships in entity classes or other ways ?
@sdscode8 ай бұрын
Yes
@sureshmanne7245 Жыл бұрын
26:30 is it mandatory or neccesary that we create a new 3rd table with @ManyToMany mapping? Can we not use @ManyToMany without a 3rd table?
@sureshmanne7245 Жыл бұрын
Also can you tell how the methods findStudentsContainingByName & findCourseLessThanPrice fetching the data with out any JPA query written in Repository classes ?
@matheuspegorari1094 Жыл бұрын
Yes it is mandatory, Many to Many relationship demands a intermediary table.
@medyazidhamlaoui2703 Жыл бұрын
thank you, I have a question, how can I add the course and assign the students of this course
@clipy57577 ай бұрын
What if we want to create course separately and then want to assign them to student ?
@SandeepKumar-se2fd2 жыл бұрын
Hey Basanta, Great Explanation. I have one doubt. From student api we are able to fetch both student and course data. Can we fetch course and enrolled student data from course api i.e. search/{price}??
@Javatechie2 жыл бұрын
Hi Sandeep yes we can do that
@SandeepKumar-se2fd2 жыл бұрын
@@Javatechie Can you please guide, how to do?
@Iamit99yadav2 жыл бұрын
Can u create same crud operation with Hibernate
@Javatechie2 жыл бұрын
We can do it easily. Instead of use EntityManager just use the hibernate session factory that's it .
@VIKASROYv Жыл бұрын
Everything works perfectly, But there is a problem While I am trying to save only students not courses It is not able to save. Is there a work around for those scenario.
@Javatechie Жыл бұрын
Can you change the cascade type and try once
@VIKASROYv Жыл бұрын
No Luck@@Javatechie , Failed to evaluate Jackson deserialization for type [[simple type, class com.example.fts.erp.entity.Student]]: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot handle managed/back reference 'defaultReference': back reference type (`java.util.Set`) not compatible with managed type (com.gradlic.fts.erp.entity.Student)
@johnsnow17572 жыл бұрын
can u tell me about put mapping
@madhusamala39212 жыл бұрын
Will this code works if other student buys the same courses , it is throwing me 'detached entity passed to persist'
@Javatechie2 жыл бұрын
Please change the cascade value to persist
@mridulrajbhar12 Жыл бұрын
@@Javatechie it doesn't works
@lovetyagi52662 жыл бұрын
please make video on how to create exokicit join(custom join query )with native and jpql query with and withut projection PLEASE JAVA TECHIE
Following the same code setup but getting this error when running: Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: Can anyone help me on this?
@RajYadav-fy4lm2 жыл бұрын
can we still enroll to your ongoing course or it would be too late?
@Javatechie2 жыл бұрын
Hi Raj you can enroll in the course now. Theory classes are only completed and you can also see the recording session of completed classes
@vengateshkannan3297 Жыл бұрын
"status": 415, I am getting unsupported media type error in postman
@Nab-dh7bl8 ай бұрын
how did you solve it, i have the same problem thanks in advance!
@srikarthickk97086 ай бұрын
Did u fix it?
@pradeepkec2 жыл бұрын
There will be an issue if u use mappedby in the child entity , if u delete the student, all the cource associated to students will also be deleted .
@Javatechie2 жыл бұрын
Is it let me check
@codingsunday37077 ай бұрын
How can we fetch Courses that student is enrolled in ?
@Javatechie7 ай бұрын
You need to trigger join query
@itsnarahari2 жыл бұрын
Bro I want to tell you something Today's days even If we are using Spring boot and JPA they are not using that they are using database queries only they are not allowing us to use jpa features like onetomany manytomany I didn't understand these 🤔 y they are doing like these
@Javatechie2 жыл бұрын
Usually people follow a microservice pattern where you should have a single database per service that is the reason they avoid using association mapping
@vijik29882 жыл бұрын
Please do all mapping CRUD operation since I am facing issues with update and delete
@vibhutimaheshwari7350 Жыл бұрын
How is this many to many? This is rather one to many (or many to one). For one student you are saving many courses but haven't demonstrated that for one new course added to table, many students are enrolled. Also, you haven't demonstrated what happens when both santosh and basant have the same course in their enrollment list. (I tried it out and observed that two copies of the same course are getting stored instead of just one)
@Javatechie Жыл бұрын
First of all this is one to many unidirectional and whatever you caught is a good point will check and update here
@vijik29882 жыл бұрын
Can u please do update and delete operation also
@meet67122 жыл бұрын
can you please give coupon for spring data jpa course
@Javatechie2 жыл бұрын
Didn't get you @Meet
@meet67122 жыл бұрын
@@Javatechie discount coupon for your udemy course of spring data jpa
@Javatechie2 жыл бұрын
I don't have any udemy course buddy. I am giving live class on unacademy and yes coupon is available. Please reach me on javatechie4u@gmail.com for any queries
@biswajeetsahoochintu23292 жыл бұрын
🙏🙏🙏
@channelcuriousity64675 ай бұрын
is your name radhakanth nayak?
@amitkadam23549 ай бұрын
I am very much confused with mappedBy
@knmuralimurali2922 Жыл бұрын
{ "productsdetails": [ { "id": "1", "pname": "Product 1", "pquantity": "10", "punitcost": "100" }, { "id": "2", "pname": "Product 2", "pquantity": "20", "punitcost": "150" } ], "productscategory": [ { "cid": "1", "Pcategory": "Category A" }, { "cid": "2", "Pcategory": "Category B" } ], "productscolour": [ { "rid": "1", "Pcolour": "Red" }, { "rid": "2", "Pcolour": "Blue" } ] } i need to post values in json can you give me code
@sanjaykumarnayak8877 Жыл бұрын
Here One thing I tried is that ,after giving @JsonManagedReference and @JsonBackReference I am unable to save the data now it is saying Media type not supported, why so?