Can view the tutorials best in Google Chrome, Mozilla Firefox, Opera, higher version of Internet Explorer

Hibernate One to Many Select Query Example

Hibernate » On Jul 22, 2011 By Sivateja

Let us see the logic for hibernate one to many mapping select query,

hibernate one to many select means, if you select the parent object then automatically its corresponding child objects will also be selected, see i have given for the logic for selecting single parent object with all its childs & all parent objects with all child objects

But mates, ensure you came through these sessions for better understand

Files required..

  • Vendor.java [pojo class]
  • Customer.java [pojo class]
  • OurLogic.java
  • Customer.hbm.xml
  • hibernate.cfg.xml
  • Vendor.hbm.xml

Vendor.java

Customer.java

Customer.hbm.xml

Vendor.hbm.xml

hibernate.cfg.xml

Select Single Parent Object With All Child

OurLogic.java

If we want to select all the parent objects will all its corresponding child objects., then the logic will be like..

Select All Parent Objects With All Childs

OurLogic.java







By [ Java/J2EE Developer & Web Designer ]
Founder of Java4s.com - Indian, lives in United States. You can contact me at sivateja@java4s.com


Comments

3 Responses to “Hibernate One to Many Select Query Example”
  1. Mandar says:

    Plz some one tell me How i use one to many mapping in hibernate for creation of three tables.
    1.discussion(discId,queId,ansId)
    2.question(queId,question,postdate)
    3.answer(ansId,answer,postDate)

    Thanks in advance

    Plz rply its argent

  2. bk says:

    hi… the information given by you is very impressive , and can you provide information about the “Detached Criteria”. Thanks

  3. basha says:

    Hi,

    what is “insert” attribute in mapping files. Can you explain clearly?

Name*
Mail*
Website



By posting your answer, you agree to our comments policy.
Most Recent Tutorials
Hibernate Recent Posts
Spring Recent Posts
Struts Recent Posts
Recomandded Links Current & UpComing Tutorials Java4s.com
Tutorials Online :
spring Hibernate struts Json Ajax Log4j Log4j
coreJava Servlets


UpComing :
JSP, Web Services [ In Progress ]
Java4s is optimized for learning java technologies, all the examples in this site are constantly reviewed to avoid errors. While using this site you agree to have read and accepted our terms of use and privacy policy
Especially i have prepared this blog by keeping fresher's in mind, however it will be very useful for real time developers too.


© 2014 Java4s All rights reserved. | strPro4Tut v(2.0) Theme designed by Team Java4s.