Question
How do you implement one to many relationships in Hibernate

Answers

- For one to many relationships we can consider the example Author and Books (i.e. one Author can have written many books).
- Below code will help you to understand how you can implement one to many relationship in hibernate.
File: Author.javapackage com.test.one.to.many;java.util.Set;public class Author implements java.io.Serializable{   private Integer authorId;   private String authorName;   private Set books;   // getter and setter}
File: Book.javapackage com.test.one.to.many;public class Book implements java.io.Serializable{   private Author author;   private Integer bookId;   private String bookName;   // getter and setter}File: Author.hbm.xmlFile: Book.hbm.xmlFile: hibernate.cfg.xml com.mysql.jdbc.Driverjdbc:mysql://localhost:3306/mytestdbrootpasswordorg.hibernate.dialect.MySQLDialecttruetrue   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q Why using swing for high performance is not a good idea ?
  • Q How adaptive do you consider yourself to the environment?
  • Q What is the difference between horizontal and vertical partitioning?
  • Q What is Landolfi’s sign?
  • Q Is the following statement correct: char ch = 'd'; if(ch < 32.00){ }?
  • Q What was the name of Felix the Cats girlfriend
  • Q Violation of something holy or sacred
  • Q Explain how the lubricating oil circulates in a diesel engine.
  • Q From everything you've observed, what problems can you cite regarding working in this career?
  • Q What is a skeleton in rmi?
  • Q What is female sex ratio per 1000 males of Karnataka state in 2011?