I'm following along with the examples in "Hibernate: A Developer's Notebook", but am using DB2 UDB 7.2 (Windows) instead of HSQL. The schema generation works fine, with Date & Time fields in the mapping document resulting in Date & Time columns in the database table.
However, when running hbm2java, the playTime field is generated as a java.util.Date.
Hibernate version:
hibernate-2.1.7b
hibernate-extensions-2.1.3
Mapping documents:
Code:
<hibernate-mapping>
<class name="com.oreilly.hh.Track" table="TRACK">
<meta attribute="class-description">
Represents a single playable track in the music database.
@author Jim Elliott (with help from Hibernate)
</meta>
<meta attribute="implement-equals">true</meta>
<id name="id" type="int" column="TRACK_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="title" type="string" not-null="true"/>
<property name="filePath" type="string" not-null="true"/>
<property name="playTime" type="time">
<meta attribute="field-description">Playing time</meta>
</property>
<property name="added" type="date">
<meta attribute="field-description">When the track was created</meta>
</property>
<property name="volume" type="short">
<meta attribute="field-description">How loud to play the track</meta>
</property>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():n/a
Full stack trace of any exception that occurs:n/a
Name and version of the database you are using:DB2 UDB 7.2 (Windows)
The generated SQL (show_sql=true):n/a
Debug level Hibernate log excerpt:n/a
Generated java code excerpt:Code:
package com.oreilly.hh;
import java.io.Serializable;
import java.util.Date;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
* Represents a single playable track in the music database.
* @author Jim Elliott (with help from Hibernate)
*
*/
public class Track implements Serializable {
/** identifier field */
private Integer id;
/** persistent field */
private String title;
/** persistent field */
private String filePath;
/** nullable persistent field */
private Date playTime;
/** nullable persistent field */
private Date added;
/** nullable persistent field */
private Short volume;
/** full constructor */
public Track(String title, String filePath, Date playTime, Date added, Short volume) {
this.title = title;
this.filePath = filePath;
this.playTime = playTime;
this.added = added;
this.volume = volume;
}
<<snip>>