Skip to content

Hibernate

July 23, 2008

Hibernate
==============================
The no-argument constructor is a requirement for all persistent classes;
native, which picks the best strategy depending on the configured database (dialect).
Hibernate supports database generated, globally unique, as well as application assigned identifiers (or any strategy you have written an extension for).

These types are so called Hibernate mapping types, converters which can translate from Java to SQL data types and vice versa.
Again, Hibernate will try to determine the correct conversion and mapping type itself if the type attribute is not present in the mapping.
In some cases this automatic detection (using Reflection on the Java class) might not have the default you expect or need.
This is the case with the date property. Hibernate can’t know if the property (which is of java.util.Date) should map to a SQL date, timestamp, or time column.

To connect to the database: hibernate.properties file, a slightly more sophisticated hibernate.cfg.xml file, or even complete programmatic setup
Task:
– Run a simple hibernate application. (Small batch program)  – Along with Junit.?
– Use EhCache along with Hibernate to improve performance.

Hibernate – create 3 files:

1. Hibernate.cfg.xml – has connection setup details (Configuration file)
2. Entity.hbm.xml – has data related to entities. (Mapping file)
3. HibernateUtil – that creates the Session Factory from Configuration file

This thread-bound programming model  allows flexible layering of your code

Advertisements
No comments yet

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: