Hibernate Tutorial part 9 - Unidirectional VS Bidirectional One to One Mapping, CascadeType

www.gontu.org in this tutorial, we will learn what is the real use of a one to one mapping in hibernate along with other important concepts which we did not learn in the last tutorial i.e what is a cascadeType in hibernate, what is a Unidirectional one to one mapping and what is a Bidirectional one to one mapping.
Unidirectional vs bidirectional one to one mapping in hibernate.
www.gontu.org

Пікірлер: 59

  • @nzchamp
    @nzchamp6 жыл бұрын

    Thanks gontu.I have searched a lot of tutorials for hibernate but no tutorial is like your tutorial. Simply awsome.

  • @gontuseries
    @gontuseries10 жыл бұрын

    in the next tutorial, we will learn the concept of Many to one / one to Many mapping in hibernate...

  • @Ravikumar-gj6qw

    @Ravikumar-gj6qw

    4 жыл бұрын

    Bro please uploading spring boot, microservices its urgent

  • @DhirajSinghPro
    @DhirajSinghPro10 жыл бұрын

    I really appreciate your efforts. By following your Hibernate Tutorials i have learned a lot and its as interesting as any entertainment series. please upload more and more so that we can get quality learning. thanks

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    Dhiraj Singh Hi Dhiraj Singh, thanks for liking my tutorials. many more tutorials are coming up soon in the hibernate series of tutorials. Keep visiting for updates. Happy learning.

  • @balasubramanian8081
    @balasubramanian80818 жыл бұрын

    really amazing!!before i watch ur videos i was confusing in hibernate concepts bt now i have cleared...i became your big fan..

  • @9305347887
    @93053478875 жыл бұрын

    Your tutorial is really amazing,the way you explain is crystal clear and helps me to easily get the concept,I have watched almost every video on hibernate but still no 1 explained ,which table will hold the primary key and who will hold the foreign key in OneToOne Mapping and this was really confusing for me But by watching your tutorial i learned this concept.Thanks alot, I think this is the best Hibernate tutorial on youtube , as other youtube tutors are really lagging to clear the concepts.

  • @ankitkumar-ln3gs
    @ankitkumar-ln3gs4 жыл бұрын

    I seen all vedio that are great growing future of java developer ,, thanku so much sir.

  • @satinder839
    @satinder8399 жыл бұрын

    your way of explanation is really very good, i understood each concept clearly...Thankyou very much for your Tutorial.

  • @25gaines
    @25gaines10 жыл бұрын

    Your tutorials are great they really help me a lot! please keep posting

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    thank you 25gaines. Much more tutorials in hibernate series are coming up. Happy learning.

  • @RamMohan222
    @RamMohan2229 жыл бұрын

    Thanks for providing these tutorials, it's really helpful to me.., i'm also following ur spring and SpringMVC. this is the rite place for learning technologies from basic.

  • @chandramohanvr4754
    @chandramohanvr47549 жыл бұрын

    Dude !!!!! Awesome work bro ! I was so badly needing an explanation for the reason of the one-to-one mapping definition when it was already designed at DB level using foreign key. :D Thumbs up ! (y)

  • @gontuseries

    @gontuseries

    9 жыл бұрын

    Chandra Mohan Hi Chandra, thanks for all the appreciation :) Happy learning... many more tutorials are coming up so keep visiting for updates. Happy learning...

  • @jcfrane7916
    @jcfrane791610 жыл бұрын

    Great Tutorials!

  • @linus508
    @linus50810 жыл бұрын

    Thanks a lot. very useful tutorial

  • @inayathussain789
    @inayathussain7897 жыл бұрын

    I learned hibernate only through your video.After searching a lot on web. i will suggest other only your video to learn hibernate in beginning.

  • @sanjay6106
    @sanjay61068 жыл бұрын

    Great Work Bro!!!! Very useful video, I Like it

  • @architapatnaik8116
    @architapatnaik81168 жыл бұрын

    Thank you so much sir....Awesome tutorial.

  • @surajpanade7745
    @surajpanade77457 жыл бұрын

    Superb explanation, very good way of presenting

  • @abhinandanchougule8871
    @abhinandanchougule88717 жыл бұрын

    you are just awesome sir. Tysm It really helps me

  • @TotallyNotGhostStallone
    @TotallyNotGhostStallone6 жыл бұрын

    Thanks for the help understanding CascadeType

  • @raujhkumar
    @raujhkumar7 жыл бұрын

    best tutorial ,best way to learn easy from this ,Thanks sir

  • @kalkidanf
    @kalkidanf9 жыл бұрын

    great job bro! keep it up!

  • @johnwesley4162
    @johnwesley416210 жыл бұрын

    Hi Gontuseries, Great Job! Your presentation is perfect, please continue to contribute more.

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    Hi John Wesley, thank you for liking my work! Keep visiting for updates. Happy learning.

  • @speedbreaker5642
    @speedbreaker56427 жыл бұрын

    it's very helpful, #ankush , your videos are very helpful for beginners like us.

  • @ramsikarwar7
    @ramsikarwar79 жыл бұрын

    Hey, It really nice 1, helps me a lot thanks buddy :)

  • @girishgandhi5520
    @girishgandhi55209 жыл бұрын

    Excellent Video.. Thanks

  • @udithadissanayake8103
    @udithadissanayake81039 жыл бұрын

    perfectly explain everything nice work Thumbs up

  • @solankivaibhav7448
    @solankivaibhav74486 жыл бұрын

    great work

  • @amritpalsingh5320
    @amritpalsingh53205 жыл бұрын

    This was so good

  • @faizalhussainsyed9770
    @faizalhussainsyed97707 жыл бұрын

    super video bro

  • @oueslaatirania1708
    @oueslaatirania17087 жыл бұрын

    thank you very very very very much it helps much much much much

  • @venkatvino6639
    @venkatvino663910 жыл бұрын

    Thanks a lot. this tutorial is very useful.

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    thank you Venkat vino... Happy learning.

  • @zakariajaadi8941
    @zakariajaadi89419 жыл бұрын

    gontuseries thank u for this awsome tutorial, i still have a question that is really bothering me, what if i have a parent object that is already present in database , and i want to insert a child object and associate it with the parent object that is already existring in database ? does removing "cascade" property will do the job. ? thanks in advance

  • @sanjayajanakantha7883
    @sanjayajanakantha78833 жыл бұрын

    Thank you

  • @venkatz0033
    @venkatz003310 жыл бұрын

    Thanks

  • @AkshayPatel_96
    @AkshayPatel_966 жыл бұрын

    Need Help, Well when i save child class which is one to one mapped with parent class, the insert operation works well and data is save in both tables. But when i try to delete child class, the data related to that in parent class remains while it only deletes in child class, already used CascadeType.All

  • @MrStabilite
    @MrStabilite6 жыл бұрын

    think you so much

  • @saddammd
    @saddammd8 жыл бұрын

    Thanks,

  • @chiragsoni7592
    @chiragsoni75926 жыл бұрын

    nice videos

  • @iskonjsk
    @iskonjsk10 жыл бұрын

    Hello, In class Main you have written studentDetail.setStudent(student), if i dont write this then also it works. But reference of Student POJO class is required in StudentDetail POJO class. Can you please let me know how hibernate deals with it ?

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    Hi Akhilesh Anand, in a one to one mapping case: when you say you did not write studentDetail.setStudent(student) in the code. Technically, hibernate does not impose any restriction for you to specify it always at static compilation time. But, when you run the application, if hibernate expects this line and it does not find it up there, it may throw an exception in certain cases (like attempted to assign id from null one-to-one property) or it may proceed and do the operation (which may not yield proper required output).

  • @sandeepdesai7168
    @sandeepdesai71687 жыл бұрын

    gr8 tutorial

  • @snoisoni3482
    @snoisoni348210 жыл бұрын

    Thanks for the early response. Can u plz clearly explain this annotation along with the properties used for this. @GeneratedValue(generator= "newGenerator") //name of the primary key generator @GenericGenerator(name= "newGenerator", strategy = "foreign",parameters = {@Parameter(value= "student", name = "property") })

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    Hi Snoi soni, I hope this will explain it @GenericValue annotation tells what is the strategy to obtain the value for the student_id field value at runtime ( in case you do not specify any property value in it - it means use the default strategy... means hibernate is going to generate the value of student_id automatically itself) In case you specify some properties value in it - like in this case - @GeneratedValue(generator= "newGenerator") - it means you are telling hibernate: hey do not use the default strategy for generating value but use the strategy which is defined using the "newGenerator" - generator code. Now, question is where is this "newGenerator" code? answer is - just below to it you write one more annotation i.e. @GenericGenerator(name= "newGenerator", strategy = "foreign",parameters = {@Parameter(value= "student", name = "property") }) ---------------------- here you are simply defining what is "newGenerator" so you are saying here to hibernate - hey hibernate "newGenerator" is the name of the code which will provide some value as per the strategy-----> this value should be same as that of the primary key column of the student class [strategy="foreign", parameters = {@Parameter(value= "student", name = "property") }] Cheers

  • @nirajnayan

    @nirajnayan

    8 жыл бұрын

    @gontuseries Good work. I am using same strategy as you defined but value in you have created for foreign key in studentdetail table as student_id is not working. it is taking null value. Please give solution .

  • @avinashdudala9490
    @avinashdudala94903 жыл бұрын

    Hi Ankush y u haven't used mapped By annotation for bidirectional... Here?????? on same thing one2many u used mapped By annotation .... Can you explain y

  • @lebiedtahayounes1206
    @lebiedtahayounes12068 жыл бұрын

    First Thanks a lot for this tutorial. I have a question, in the Main if we don't create a reference to the parent object (studentDetail.setStudent (student)) why we got this error ? Exception in thread "main" org.hibernate.id.IdentifierGenerationException: attempted to assign id from null one-to-one property

  • @dknanya

    @dknanya

    6 жыл бұрын

    check this stackoverflow.com/questions/11104897/hibernate-attempted-to-assign-id-from-null-one-to-one-property-employee

  • @f_ftactics7928
    @f_ftactics79288 жыл бұрын

    so student class is inside studentDetail class, and student class is a parent table. If it is other way around, then studentDetail is the parent class? I am little confused. Thanks

  • @arkadey3241
    @arkadey32416 жыл бұрын

    Hi sir, I just sent you one mail with my issue with One to One mapping.

  • @snoisoni3482
    @snoisoni348210 жыл бұрын

    In bidirectional one to one mapping , how we will come to know who is parent class & who is chaild class?

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    Hi snoi soni, mappings can not tell which one is a parent class and which one is a child class. These are helpful for only two purposes: navigational access (unidirectional or bidirectional) and performing mapping related tasks (e.g in the demo, using the same value of id from Master table in the child table). Now, question comes, how do we know which one is a Parent and which one is a child class in a bidirectional (or, even in a unidirectional mapping) - it may be by looking at the @GeneratedValue annotation in any of the classes: in master class (in the demo, Student class) hibernate will be generating value of student_id using some auto value generation mechanism and in the child class (in the demo, StudentDetail class) will have its value like @GeneratedValue(generator = "newGenerator") //name of the primary key generator @GenericGenerator(name = "newGenerator", strategy = "foreign",parameters = { @Parameter(value = "student", name = "property") }) point to see is strategy = "foreign" . This is one of the ways to tell which is a parent and which one is a child class in case of a one to one mapping (in both unidirectional as well as bidirectional case)

  • @tribalenero
    @tribalenero10 жыл бұрын

    Good job ... ;-)

  • @gontuseries

    @gontuseries

    10 жыл бұрын

    Hi Michele Demundo, thanks for liking my tutorials. Many more tutorials are coming up in the hibernate series like Cache, mappedby etc etc . Keep visiting and happy learning.

  • @centurion3708
    @centurion37083 жыл бұрын

    No offense, but for an indian tutorial this one is really good