Target AudienceThis tutorial is designed for Java programmers who need to understand the Hibernate framework and its application.
Prerequisites:Before proceeding with this tutorial you should have a good understanding of the Java programming language and also good understanding of SQL.
This is 1 of 8 parts of tutorial series
Part-1:Introduction to hibernate framework Part-2:Hibernate hello world example in eclipse Part-3:Hibernate one to one mapping example Part-4:Hibernate one to many mapping example Part-5:Hibernate many to many mapping example Part-6:Hibernate inheritance:Table per class hierarchy Part-7:Hibernate inheritance:table per subclass Part-8:Hibernate inheritance:Table per concrete classBefore understanding hibernate framework,we need to understand Object Relational Mapping(ORM).
What is ORM?ORM is a programming method to map the objects in java with the relational entities in the database.In this,entities/classes refers to table in database,instance of classes refers to rows and attributes of instances of classes refers to column of table in database.This provides solutions to the problems arise while developing persistence applications using traditional JDBC method. This also reduces the code that needs to be written.
Need for tools like hibernate:
- High-level object-oriented API
- Less Java code to write
- No SQL to write
- Sophisticated caching
- Lazy loading
- Eager loading
- A lot less code to write
- ORM framework generates database-specific SQL for you
What is hibernate?
Architecture of hibernate :
Core classes of hibernate are:
Configuration configuration=new Configuration(); configuration.configure(); ServiceRegistry sr= new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry(); SessionFactory sf=configuration.buildSessionFactory(sr);SessionFactory object is created with the help of configuration object.