Wednesday, January 21, 2015

Hibernate 4.2.6 note

Hibernate 4.2.6 note
1.
The main Hibernate ORM artifact is named hibernate-core. If you wish to use JPA support, you would instead name hibernate-entitymanager.
To use Hibernate ORM in your own project you just need to name a dependency on it in your project.
From Maven
<dependency>
   <groupId>org.hibernate</groupId>
   <artifactId>hibernate-core</artifactId>
   <version>4.3.8.Final</version>
</dependency>

hibernate-core
The main artifact, needed to build applications using the native Hibernate APIs including defining metadata in both annotations as well as Hibernate's own hbm.xml format.
hibernate-entitymanager
Represents Hibernate's implementation of JPA
hibernate-c3p0
Provides integration between Hibernate and the C3P0 connection pool library.

2.
The resource file hibernate.cfg.xml defines Hibernate configuration information.
The resource attribute of the mapping element causes Hibernate to attempt to locate that mapping as a classpath resource, using a java.lang.ClassLoader lookup.
Hibernate needs to create objects for you, using Java Reflection. The constructor can be private. However, package or public visibility is required for runtime
proxy generation and efficient data retrieval without bytecode instrumentation.

3.
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
In the absence of a column attribute, Hibernate uses the property name as the column name.
The title mapping also lacks a type attribute. The types declared and used in the mapping files are neither Java data types nor SQL database types. Instead, they
are Hibernate mapping types.
Hibernate mapping types are converters which translate between Java and SQL data types.
Hibernate attempts to determine the correct conversion and mapping type autonomously if the type attribute is not present in the mapping, by using Java
reflection to determine the Java type of the declared property and using a default mapping type for that Java type.

No comments:

Post a Comment