The no-argument constructor is required to instantiate an object of this class through reflection.
We will omit the DTD declaration in future examples to shorten the code. It is of course not optional.
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. We preserve full date and time information by mapping the property with a timestamp
converter.
Hibernate is the layer in your application which connects to this database, so it needs connection information. The connections are made through a JDBC connection pool, which we also have to configure. The Hibernate distribution contains several open source JDBC connection pooling tools, but will use the Hibernate built-in connection pool for this tutorial.