-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: hbm2java generates Time field as Date
PostPosted: Wed Nov 24, 2004 11:14 am 
Newbie

Joined: Wed Nov 24, 2004 12:07 am
Posts: 1
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>>


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 24, 2004 9:21 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The Date class includes a time attribute. Not sure what the problem might be here.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.