Saturday, August 27, 2016

Hibernate

Hibernate is a high-performance Object/Relational persistence and query service which is licensed under the open source GNU Lesser General Public License (LGPL) and is free to download. Hibernate not only takes care of the mapping from Java classes to database tables (and from Java data types to SQL data types), but also provides data query and retrieval facilities.

It involves two files :-
  1. Hibernate configuration file (.cfg.xml)
  2. Hibernate mapping file (.hbm.xml) 
Both these files are places in src folder. The configuration file is the main and the mapping file is declared inside it inside <mapping> tag with attribute resource.


Hibernate configuration file :-




<hibernate-configuration>  
<session-factory>  
<property name="hibernate.dialect"> org.hibernate.dialect.MySQLDialect </property>  
<property name="hibernate.connection.driver_class"> com.mysql.jdbc.Driver </property> 
 <!-- Assume test is the database name -->  
<property name="hibernate.connection.url"> jdbc:mysql://localhost/test </property>  
<property name="hibernate.connection.username"> root </property>  
<property name="hibernate.connection.password"> root123  </property>  
<!-- List of XML mapping files -->  
<mapping resource="Employee.hbm.xml"/> 
 </session-factory>  
</hibernate-configuration>

Properties :- 
hibernate.dialect  :-

Hibernate Mapping File :-

SpringBoot Application Event Listeners

When a spring boot application starts few events occurs in below order ApplicationStartingEvent ApplicationEnvironmentPreparedEvent Applicat...