Module - 10 - Hibernate
Module - 10 - Hibernate
Hibernate
Introduction to Hibernate
<hibernate-configuration>
<session-factory>
<property
name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</
property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@charan-
HP:1521:XE</property>
<property name="hibernate.connection.username">userid</property>
<property name="connection.password">password</property>
<property
name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="show_sql">false</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>a
Hibernate.cfg.xml
</class>
</hibernate-mapping>
factory= conf.buildSessionFactory(builder.build());
configuration object configure() uses the mappings and properties specified in the
hibernate.cfg.xml.
ServiceRegistry is used to load the list of services in the hibernate.cfg.xml. Apart
from settings, some services to be exeucted also can be provided in the configuration
file.
Using these services build the sessionFactory so that openSession of Session will
connect to the database for transactions.
For Add/list/update/delete
Many to one...
http://2.bp.blogspot.com/-QyLSI1zqdLA/T56sonkqKRI/AAAAAAAA
A5Y/W7A3jq0-I78/s1600/many-to-one.jpg
Many to Many --> Pls place icons for Employees and Projects
rather than ellipses.
http://www.expertsmind.com/CMSImages/411_Mapping
%20cardinality-Many-to-Many.png
One to One relationship mapping.
<hibernate-mapping>
<id name="id">
<generator class="increment"></generator>
</id>
<property name="name"></property>
<property name="college_address"></property>
</subclass>
<property name="house_address"></property>
</subclass>
</class>
Caching in hibernate