Hibernate's primary feature is mapping from Java classes to database tables, and mapping from Java data types to SQL data types.Hibernate also provides data query and retrieval facilities.It generates SQL calls and relieves the developer from the manual handling and object conversion of the result set.The mapping of Java classes to database tables is implemented by the configuration of an XML file or by using Java Annotations.In few articles, they even suggested that just forget about what is “inverse”, and always put inverse=”true” in the collection variable. This statement is always true – “put inverse=true in collection variable”, but do not blindfold on it, try to understand the reason behind is essential to optimal your Hibernate performance.
It provides a framework for mapping an object-oriented domain model to a relational database.
A List is a java collection that stores elements in sequence and allow duplicate elements.
The user of this interface has precise control over where in the list each element is inserted.
The following My SQL script creates the database and the two tables:create database stockdb; use stockdb; CREATE TABLE `category` ( `category_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, PRIMARY KEY (`category_id`) ); CREATE TABLE `product` ( `product_id` int(11) NOT NULL AUTO_INCREMENT, `name` varchar(45) NOT NULL, `description` varchar(512) NOT NULL, `price` float NOT NULL, `category_id` int(11) NOT NULL, PRIMARY KEY (`product_id`), KEY `fk_category` (`category_id`), CONSTRAINT `fk_category` FOREIGN KEY (`category_id`) REFERENCES `category` (`category_id`) );package net.codejava.hibernate; import
Table; @Entity @Table(name = "CATEGORY") public class Category package net.codejava.hibernate; import javax.persistence. Each has its own pros and cons, so it’s up to you to decide which best suites your need.