Collection of basic types
Use @ElementCollection annotation along with @CollectionTable (if you want to control the name of table), and @Column (name of column to represent value of simple type)
updating...
Person is an abstract class. So either a person will exist as Employee or Physician. Hibernate mapping for Person is shown below:


Session session = HibernateUtil.getSessionFactory().openSession(); session.beginTransaction(); Employee emp = new Employee(); emp.setName("Amer Sohail"); emp.setPay(123f); session.save(emp); Physician phy = new Physician(); phy.setName("Dr. Amer Sohail"); phy.setPay(345f);
phy.setBillingAddress("Lahore");
phy.setSpeciality("Pediatrics"); session.save(phy); session.getTransaction().commit(); session.close(); 
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
List emp = session.createQuery("from Person emp").list();
if (emp != null && emp.size() > 0)
{
for (int index = 0; index <>
{
System.out.println("Name of employee is " +((Employee)emp.get(index)).getName());
if (emp.get(index) instanceof Person)
System.out.println("This is person");
if (emp.get(index) instanceof Employee)
System.out.println("This is Employee");
if (emp.get(index) instanceof Physician)
System.out.println("This is Physician");
}
}
session.getTransaction().commit();
session.close();
Name of employee is Amer Sohail
This is person
This is Employee
Name of employee is Dr. Amer Sohail
This is person
This is Employee
This is Physician
List emp = session.createQuery("from Employee emp where type = Employee").list();
Session session =HibernateUtil.getSessionFactory().openSession(); session.beginTransaction();
for (int index = 0; index <> Book book = new Book();
book.setAuthor("amer");
book.setIsbn("34343");
book.setName("Hibernate " + index);
Publisher pub = new Publisher();
pub.setName("Publisher " + index);
book.setPublisher(pub);
book.setPublishDate(new Date());
session.save(book);
}
session.getTransaction().commit();
session.close();
StatelessSession session = HibernateUtil.getSessionFacgtory().openStatelessSession(); session.beginTransaction();
for (int index = 0; index < style="font-style: italic; color: rgb(255, 153, 102);"> {
Book book = new Book();
book.setAuthor("amer");
book.setIsbn("34343");
book.setName("Hibernate " + index);
Publisher pub = new Publisher();
pub.setName("Publisher " + index);
book.setPublisher(pub);
book.setPublishDate(new Date());
session.insert(pub);
session.insert(book);
}
session.getTransaction().commit();
session.close();