Thanks for your suggestion. I can't seem to get around this problem, which is likely my error but I don't see it. I'm expecting the generated code to use "short" not "Short". I'm now using:
hibernate version 3.0 final
mapping file: 3.0
Here's the revised mapping file:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<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>
<id name="id" type="int" column="TRACK_ID">
<meta attribute="scope-set">protected</meta>
<generator class="native"/>
</id>
<property name="title" type="string">
<meta attribute="use-in-tostring">true</meta>
<column name="TITLE" not-null="true" index="TRACK_TITLE"/>
</property>
<property name="filePath" type="string" not-null="true"/>
<property name="playTime" type="time">
<meta attribute="field-description">Playing time</meta>
</property>
<set name="comments" table="TRACK_COMMENTS">
<key column="TRACK_ID"/>
<element column="COMMENT" type="string"/>
</set>
<property name="added" type="date">
<meta attribute="field-description">When the track was created</meta>
</property>
<property name="volume" type="short" not-null="true">
<meta attribute="field-description">How loud to play the track</meta>
</property>
</class>
<query name="com.oreilly.hh.tracksNoLongerThan">
<![CDATA[
from com.oreilly.hh.Track as track
where track.playTime <= :length
]]>
</query>
</hibernate-mapping>
Here's the generated code:
package com.oreilly.hh;
import java.io.Serializable;
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 {
/** nullable persistent field */
private String title;
/** nullable persistent field */
private String filePath;
/** nullable persistent field */
private java.util.Date playTime;
/** nullable persistent field */
private java.util.Set comments;
/** nullable persistent field */
private java.util.Date added;
/** nullable persistent field */
private Short volume;
/** full constructor */
public Track(String title, String filePath, java.util.Date playTime, java.util.Set comments, java.util.Date added, Short volume) {
this.title = title;
this.filePath = filePath;
this.playTime = playTime;
this.comments = comments;
this.added = added;
this.volume = volume;
}
/** default constructor */
public Track() {
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getFilePath() {
return this.filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/**
* Playing time
*/
public java.util.Date getPlayTime() {
return this.playTime;
}
public void setPlayTime(java.util.Date playTime) {
this.playTime = playTime;
}
public java.util.Set getComments() {
return this.comments;
}
public void setComments(java.util.Set comments) {
this.comments = comments;
}
/**
* When the track was created
*/
public java.util.Date getAdded() {
return this.added;
}
public void setAdded(java.util.Date added) {
this.added = added;
}
/**
* How loud to play the track
*/
public Short getVolume() {
return this.volume;
}
public void setVolume(Short volume) {
this.volume = volume;
}
public String toString() {
return new ToStringBuilder(this)
.append("title", getTitle())
.toString();
}
}
|