Это видео недоступно.
Сожалеем об этом.

#13 Hibernate Tutorial | Mapping Relations Practical

Поделиться
HTML-код
  • Опубликовано: 18 янв 2017
  • Hibernate is ORM i.e. Object relational mapping tool.
    Hibernate mapping relations are:
    @Many-to-One
    @One-to-One
    @One-toMany
    @Many-to-Many
    Trainer: Navin Reddy
    Github :- github.com/nav...
    Check out our website: www.telusko.com
    Follow Telusko on Twitter: / navinreddy20
    Follow on Facebook:
    Telusko : / teluskolearnings
    Navin Reddy : / navintelusko
    Follow Navin Reddy on Instagram: / navinreddy20
    Subscribe to our other channel:
    Navin Reddy : / @navinreddy
    Telusko Hindi :
    / @teluskohindi
    Subscribe to the channel and learn Programming in easy way.
    Java Tutorial for Beginners : goo.gl/p10QfB
    Scala Tutorials for Java Developers : goo.gl/8H1aE5
    C Tutorial Playlist : goo.gl/8v92pu
    Android Tutorial for Beginners Playlist : goo.gl/MzlIUJ
    XML Tutorial : goo.gl/Eo79do
    Design Patterns in Java : goo.gl/Kd2MWE
    Socket Programming in Java : goo.gl/jlMEbg
    Spring MVC Tutorial : goo.gl/9ubbG2
    OpenShift Tutorial for Beginners : goo.gl/s58BQH
    Spring Framework with Maven : goo.gl/MaEluO
    Sql Tutorial for Beginners : goo.gl/x3PrTg
    String Handling in Java : goo.gl/zUdPwa
    Array in Java : goo.gl/uXTaUy
    Java Servlet : goo.gl/R5nHp8
    Exception Handling in Java : goo.gl/N4NbAW

Комментарии • 150

  • @miadinh6381
    @miadinh6381 3 года назад +13

    0:00: Intro
    2:04: OneToOne
    4:42: OneToMany
    8:23: ManyToOne
    11:12: ManyToMany

  • @duppalabalakrishna2294
    @duppalabalakrishna2294 7 лет назад +51

    in Eclipse mars version press Alt+shift+R to change the variable or object name at once.

    • @sayalighonge
      @sayalighonge 6 лет назад +9

      Eclipse version doesn't matter..this shortcut works with all versions of eclipse.

  • @prasadpandit72620
    @prasadpandit72620 6 лет назад +7

    Hi Navin Sir, to replace any word in eclipse .. just select it.. press control +1.. and rename.. save

  • @bmiguelmf
    @bmiguelmf 5 лет назад +5

    Thank you for your "education" Navin! I'm really learning from your videos. Keep the good work.

  • @chiragagrawal4528
    @chiragagrawal4528 7 лет назад +3

    for refractor to variable on Windows u can use
    alt+shift+R
    and also select the variable that you want to change. for Mac u can search how u can get it

  • @Ajh9998
    @Ajh9998 7 лет назад +2

    You can change 's' to 'student' in one go if you select the 's', right click and refactor->rename. This changes 's' to 'student' in the same class.

  • @nehamehta6186
    @nehamehta6186 6 лет назад

    Hi , to change the name once using eclipse, you can right click on that reference variable , right click ->select refactor ->-select Rename ->change the value as expected .

  • @javacoding6054
    @javacoding6054 7 лет назад +9

    bro, please make one video for how to save image files into database and how to retrieve image files from database

  • @PratulKarande
    @PratulKarande 3 года назад

    i took whole day to understand mappings from different sources.. was still not clear concept.. saw this 15 mins video, now its crystal clear.

  • @jasper5016
    @jasper5016 4 года назад

    Thanks a lot. This mapping thing was bugging me a lot. I have seen so many videos but only you were able to clear all my doubts. Thanks again.

  • @shivpratapsingh1014
    @shivpratapsingh1014 5 лет назад +2

    Hello Navin Sir, you should use Alt+Shift+R for replacing all the occurence on an objectName in any version of eclipse.

  • @kumu2030
    @kumu2030 7 лет назад +20

    Your onetomany example will not work, when I'm setting student.getLaptops().add(laptop), no data is updated in laptop table for student.
    But if I do, laptop.setStudent(student) then its working fine.
    Please let me know, If I'm correct ?

    • @punitshrestha3281
      @punitshrestha3281 7 лет назад

      I think you're right. Also you need to persist student before laptop.

    • @manjunathab1716
      @manjunathab1716 7 лет назад +3

      Its quite common that , you need to save the student_id (foreign key) in laptop table. So obviously you need use laptop.setStudent(StudentObj)

    • @niranjanmaharana9089
      @niranjanmaharana9089 7 лет назад +1

      No. It's not required. It will update it automatically. It will first search the student table with the given student_rollNo. If available it will inserts laptop straight forward. Otherwise, It will first insert the laptop and then the student. And after inserting student, It will update laptop with that student_rollNo value from student table. You can try and see the hibernate query for reference.

    • @nevrosolutions9548
      @nevrosolutions9548 5 лет назад +7

      So then why not it happened to us , (student id not save in laptop table unless you persist it as laptop.setStudent(StudentObj) )? Can you explain it and any possible reason

    • @harshitpanchal
      @harshitpanchal 3 года назад

      @@niranjanmaharana9089 then why im getting null reference in laptop table

  • @nandiniverma5273
    @nandiniverma5273 7 месяцев назад

    This is best explanation and implementation of mappings. Thanks a lot.

  • @TimC0x
    @TimC0x 5 лет назад +1

    Your videos are flashing!!! My eyes have all fallen out...

  • @user-bu6di4xm6m
    @user-bu6di4xm6m 11 месяцев назад

    shift F6 and press enter ,you can add newname and it will add everywhere

  • @user1994gms
    @user1994gms 3 года назад

    it's refactoring.. It's in eclipse. select and right click and select refactor.. everything will be chnaged

  • @vakkalahari5449
    @vakkalahari5449 2 года назад

    I learnt from your videos many things sir !!!Thanks lot

  • @akhilshrivastava3319
    @akhilshrivastava3319 7 лет назад +2

    You may use refractor in eclipse

  • @haripriya8034
    @haripriya8034 Год назад

    Such a great explanation Sir. Thank you.

  • @jkkumar2105
    @jkkumar2105 2 года назад

    Thanks for clear explanation. I would like to know the update part in ManyToOne relationship. Say you have student with Dell and Mac today and tomorrow he got Dell And Sony. Here it should delete Mac and relate new Sony.

  • @raviranjan8238
    @raviranjan8238 5 лет назад

    thank you telusko...It saved my life..nice work...

  • @Jendukiee_2013
    @Jendukiee_2013 5 лет назад

    Thank You For Making My Fundamentals Clear.

  • @jagadeeshchowdary159
    @jagadeeshchowdary159 6 лет назад

    Double click on s and then select refactor and type what ever u need , then name changes in all the places in editor

  • @amanchaturvedi6365
    @amanchaturvedi6365 3 месяца назад

    In Intellij, I press SHIFT + F6 to rename a variable

  • @chanduputta670
    @chanduputta670 5 лет назад

    You can use Alt+Shift+R in eclipse to change the variable name in all the places in that method.

  • @AnandChaugule
    @AnandChaugule 6 лет назад

    Navin in Eclipse we use refactor to references of variable and methods as class also. (Alt + shift + r) is shortcut to use refactor.

  • @gbnaveen91
    @gbnaveen91 4 года назад +1

    Alt+Shift+r
    to change name of variables

  • @mdzakirhussain5893
    @mdzakirhussain5893 10 месяцев назад

    pls show one example with auto increment applied for both laptop id and student id. getting "foreign key constraint". I have also gone through sql query. there is error in it.

  • @alifathizadeh1356
    @alifathizadeh1356 3 года назад

    I love you man, your tutorials are very very good.

  • @raja4sekhar
    @raja4sekhar 6 лет назад

    3.26 min, use Alt+Shift+R then you can rename the object and all the recurrences will be changed automatically

  • @birdofhermes6152
    @birdofhermes6152 3 года назад

    Thanks a lot for this helpful video

  • @sheebaashraf
    @sheebaashraf 2 года назад

    Excellent Stuff

  • @gangadharreddy4606
    @gangadharreddy4606 6 лет назад

    you can do ctrl+f and replace all.....not depending on the eclipse shortcuts

  • @rahulmalgujar1110
    @rahulmalgujar1110 5 лет назад

    Thank you so much sir all my doubts have been clear.
    Sir can you please create a vedio on how map struct works in jpa.

  • @highlyPriased
    @highlyPriased 3 года назад

    you just earned a new sub man!

  • @venkatthasan3455
    @venkatthasan3455 Год назад

    While using OneToMany and ManyToOne..the foreign key column being included in the table always having NULL value... How do I resolve that?

  • @ranjit.pokale
    @ranjit.pokale 6 лет назад

    Hey navin, i love the way you explain tge things.. I have seen so many videos of yours and it helped me lot to grow technically.
    And u wanna know hw to rename a variable so that it rename all its references. So it is possible with Eclipse use Ctrl+Shift+1 and it will give you option, u have to choose first and then rename wherever u want.

  • @mirageman2
    @mirageman2 Год назад

    Great explained, thanks.

  • @erickramones2167
    @erickramones2167 5 лет назад +1

    many to one means that laptop 1 can be associated to student1 and student2. This means that we will have two records with laptop1 but if the mapping is done by laptop this wouldnt be possible. Any thoughts?

    • @mohamedrezk8807
      @mohamedrezk8807 9 месяцев назад

      i want to raise that question as well
      but i think in that case we need the third table so it can be possible

  • @satyanveshvanapalli9905
    @satyanveshvanapalli9905 5 лет назад +1

    how does birectional works for these mappings

  • @snk9106
    @snk9106 3 года назад

    How to define mappedBy and @JoinColumn in different classes.. there is lot of confusion reg. this.. can you pls explain this and let me know the video link

  • @abdulmateenchadchankar7793
    @abdulmateenchadchankar7793 6 месяцев назад

    for new version refactor option is available

  • @SKXcoding
    @SKXcoding 5 лет назад

    refactor -> rename (alt + shift + r)

  • @ameen7553
    @ameen7553 7 лет назад

    Thank You very much... it helped me a lot...

  • @erickramones2167
    @erickramones2167 5 лет назад

    i got confused, if it is a one to many relationship, one student can have multiple laptops. the student table must have the laptopID column otherwise it is not possible to create a relationship where one student can have multiple laptops. Why do we end adding a studentID column in the laptop table?

  • @Mohamed-uf5jh
    @Mohamed-uf5jh 6 лет назад

    Excellent and help ful

  • @praffullapandey146
    @praffullapandey146 4 года назад

    Very nice demo on Hibernate relationship. Can you please make one video on @OneToMany unidirectional vs bidirectional explaining how they differ ?

  • @gyannitin
    @gyannitin 4 года назад

    If we just persist parent object, it must force updates on child object as well. Can you post some video on best practices to achieve that. Currently, my parent-child update is very slow because internally it selects and then deletes from child table, then inserts new/updated data into child table [impacts performance]. How to deal with this?

  • @nguyenquan4836
    @nguyenquan4836 5 лет назад

    cool. know mappedBy so clearly, thnaks pro

  • @pranshugautam8890
    @pranshugautam8890 Год назад

    Can you explain @joincolumn also?

  • @mohaseenshaikh262
    @mohaseenshaikh262 7 лет назад

    Really good explation

  • @ameenm2540
    @ameenm2540 6 лет назад

    Hey Navin, many thanks for doing this. In the same example, could you please tell me how to set the date in case of onetomany relationship?

  • @ujjawalx7460
    @ujjawalx7460 5 лет назад +1

    do u have a github repository for these examples

  • @marvinkruger4559
    @marvinkruger4559 6 лет назад

    Nice and clear, thaaaanks!

  • @akashmohapatra1008
    @akashmohapatra1008 3 года назад

    Can we do that by not hardcoding ids?

  • @amitbff
    @amitbff 3 года назад

    pls show for multiple entries.

  • @ilhemmansouri382
    @ilhemmansouri382 3 года назад

    Great job, keep working

  • @divinity5250
    @divinity5250 5 лет назад

    Thank you for a Great video!

  • @Ajh9998
    @Ajh9998 7 лет назад

    Do you know how to handle hibernate @inheritance? If you do, would be great if you could add another video for this topic.

  • @dinakaranloganathan9962
    @dinakaranloganathan9962 3 года назад

    I have a doubt about in fetching data from two tables using manytomany

  • @abhishekchanda4916
    @abhishekchanda4916 6 лет назад

    Please Give Example with ManytoMany Relation with spring MVC. It will be helpfull for us. There are no example spring hibernate ManytoMany annotation

  • @NagaSanthosh
    @NagaSanthosh 6 лет назад

    Hi, could you please upload videos for bidirectional mapping as well.. which is really more important too..!

  • @belhouchette2oussama36
    @belhouchette2oussama36 5 лет назад

    very good thank you but what if the table laptop_student have some attribute how we can do ?

  • @abdullahal-alif9072
    @abdullahal-alif9072 4 года назад

    cloud u tell me pls u have any video ! how to connect MySQL workbench to eclipse? i am searching ur list but not found.

  • @aleemfirnas1317
    @aleemfirnas1317 6 лет назад

    Awesome series, could you please explain about FetchType Lazy, Eager and CasCadeType all annotations please ?

  • @sultanahmed5646
    @sultanahmed5646 5 лет назад

    I have a question sir..
    Suppose i have 2 students let's say navin and reddy , and 2 laptops hp and dell
    can i put entry in laptop_student table like this {navin hp} and {navin dell} without creating another class of laptop_student in eclipse?
    please explain

  • @ArjunAcharjee19
    @ArjunAcharjee19 5 лет назад

    Sir I did same with Employee and Computer class. But in my Customer database the emp_id is all null

  • @sakshamgupta4227
    @sakshamgupta4227 4 года назад

    Sir in the case of manytomany when i entered 2 entry let say a single laptop which is available for 2 students this is throwing an error because we can't store two time same laptop in laptop table....how can i manage this error???

  • @Mohamed-uf5jh
    @Mohamed-uf5jh 6 лет назад

    Excelleny and helpful

  • @deepakbhartimodi357
    @deepakbhartimodi357 6 лет назад

    Hello Sir, I have a query please solve it..I am using OneToOne annotation. If i dont make primary key auto generate. And i will set 1st person id = 1 and pdetailId = 1 and then save this data with using save(1stperson). And then again i save 2nd person id = 2 but keep pdetailId = 1 then also it is saving data which makes Many to one mapping. Can u help me to solve my thinking on this why this is happening?

  • @riteshverma879
    @riteshverma879 5 лет назад

    For rename you can just rename the reference by 'refactor' it or just 'Alt+Shit+R'

  • @praveen5163
    @praveen5163 5 лет назад

    thank you sir , if we use to-string method in both the classes, ie student and laptop class , and then if we save and run the program it shows stack overflow error in the console screen, can i know why

  • @sanchitamanocha8924
    @sanchitamanocha8924 5 лет назад

    in intellij shift+F6 to change the variable.

  • @fisahatekalign1507
    @fisahatekalign1507 4 года назад

    u'r the best

  • @rakesh1594
    @rakesh1594 4 года назад

    May be too late to ask now but please help me in understanding when the laptop instance has a student field (Many to one), noticed that student list is set with laptop and we left the student field in laptop although if done sounds like circular but please let me know.

  • @KrishnaDhakate
    @KrishnaDhakate 6 лет назад

    Alt+Shift+R in eclipse. Using Oxygen.

  • @on_a_techier_note
    @on_a_techier_note 5 лет назад

    Good tutorial

  • @saurabhwaghmare393
    @saurabhwaghmare393 4 года назад

    Hello sir, in one to many : In laptop table rollnumber column is printing nulll.

  • @travenishere6063
    @travenishere6063 5 лет назад +1

    Your videos are really good and they helped so far, only with the oneToMany Mapping, I don't really believe that it has worked since so many have been having issues and the database output is not shown. If you coud fix that, then it would be perfect

    • @travenishere6063
      @travenishere6063 5 лет назад +1

      Update: For anybody still struggeling look at stackoverflow.com/questions/38891442/hibernate-foreign-key-is-empty-while-using-mappedby
      -> You have to set the student to the laptop and the laptop to the student. Only then it worked for me.

    • @skyhi9383
      @skyhi9383 Год назад

      @@travenishere6063 This should be pinned . Than you man

  • @bittukush2009
    @bittukush2009 6 лет назад

    Your tutorial is good but please explain in details and cover more concepts.

  • @kunalgoswami1258
    @kunalgoswami1258 6 лет назад +1

    In ManytoOne annotations it is creating a student_rollno in laptop table but not fetching rollno it is showing null

    • @udayaakula5070
      @udayaakula5070 5 лет назад

      Kunal Goswami any luck brother ?

    • @deepakl391
      @deepakl391 5 лет назад

      try linking the rollno of student to laptop object [laptopobject.setStudent(student object reference)]

  • @nikhilkumarreddy5705
    @nikhilkumarreddy5705 5 лет назад

    Hello sir, can you please make a video on how to create a hibernate project on NetBeans.

  • @srikanthamble6802
    @srikanthamble6802 7 лет назад

    how to fetch data using criteria when the entities are mapped by onetomany or manytoone

  • @nadeemsadiq6975
    @nadeemsadiq6975 5 лет назад

    Sir, please make a proper vedio like using interface and full pattern

  • @chandujcsr5097
    @chandujcsr5097 6 лет назад

    Thank u very much sir

  • @chandratripuravaram3882
    @chandratripuravaram3882 2 года назад

    Alt+shift+R -- eclipse

  • @amolsarwade8579
    @amolsarwade8579 6 лет назад

    select 's' then press alt+shift+r and then rename

  • @shanmuksandeep9134
    @shanmuksandeep9134 6 лет назад

    if we need to send JSON using post call
    How to structurize JSON for oneToMany and ManyToOne (For Student and Laptop Class)
    Can any one help me out

  • @AbhishekKumar-oo4ir
    @AbhishekKumar-oo4ir 5 лет назад

    Hi Navin, ctrl+2+r

  • @mukundamhasalkar1771
    @mukundamhasalkar1771 6 лет назад +1

    Why we've use getStudent().add() here??
    Then what is the work for setStudent()??
    When we should use it then??
    Please explain sir..

    • @ujjawalx7460
      @ujjawalx7460 5 лет назад +1

      we can use the setStudent() as well .
      the way would be little different.
      List students = new ArrayList();
      Student student = new Student();
      student.addxxx();
      students.add(student);
      Laptop laptop = new Laptop();
      laptop.setStudent(students); //not student

    • @ujjawalx7460
      @ujjawalx7460 5 лет назад

      sorry if my answer came a lot late. just watching for first time. post to stackoverflow for quick reply .

  • @SaliyaRuchiranga
    @SaliyaRuchiranga 5 лет назад

    in net-beans ctrl + r to change the variable name !

  • @jaipalreddy8446
    @jaipalreddy8446 5 лет назад

    table not creating for @One-to-one mapping

  • @AbdulHaseeb-jo6lx
    @AbdulHaseeb-jo6lx 6 лет назад

    Can you please provide code for each video,so that we can check easily.....Thanks

  • @abhisheknair_music
    @abhisheknair_music 3 года назад

    Sir how to do a bidirectional one to one mapping?

  • @prathameshsurve9873
    @prathameshsurve9873 5 лет назад

    how to crate multiple records in hibernate and how to mapped

  • @udaysaisridharsirasapalli6378
    @udaysaisridharsirasapalli6378 2 года назад

    While using manytoone and onetomany... in laptop table getting foreign key value is null .. what may be the reason ?

    • @satishl2685
      @satishl2685 2 года назад

      you probably not setting the value of student into laptop object. ex : lap.setStud(sat); here lap is laptop object and sat is student object.

  • @avdhesh2010
    @avdhesh2010 5 лет назад

    Any github link where we can have the above example?

  • @srikanthkolipaka2103
    @srikanthkolipaka2103 5 лет назад

    To Rename all associated references right click - refactor - rename

  • @gamers_point2120
    @gamers_point2120 3 года назад

    visual studeio code supports that thing..!!!!!

  • @manjunathah5857
    @manjunathah5857 7 лет назад

    Dear Navin,
    I am try to persist the Customer details(Customer, Address and Country are 3 Entities are shown below),
    in Country table for each persist (for the same Country) Country is inserting the again and again, please help to overcome this problem?
    --------------------------------------------------------------------------------------------------------
    @Entity
    @Table(name = "customer")
    public class Customer {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id")
    private int id;
    @Column(name = "first_name")
    private String firstName;
    @Column(name = "last_name")
    private String lastName;
    @Column(name = "email")
    private String email;
    @OneToOne(cascade = CascadeType.ALL)
    @PrimaryKeyJoinColumn
    private Address address;
    //getters and setters
    --------------------------------------------------------------------------------------------------------
    @Entity
    public class Address {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;
    private String street;
    private String city;
    private String state;
    private long pincode;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "address")
    private Customer customer;
    @ManyToOne(cascade = CascadeType.ALL, targetEntity = Country.class)
    @PrimaryKeyJoinColumn
    private Country country;
    //getters and setters
    --------------------------------------------------------------------------------------------------------
    @Entity
    public class Country {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private int id;
    private String country;
    @OneToMany(mappedBy = "country", cascade = CascadeType.ALL, targetEntity = Address.class)
    private List address;
    //getters and setters
    --------------------------------------------------------------------------------------------------------
    help would be appreciated!
    Thank you again for everything you’ve done
    Regards,
    Manju