Joined: Tue Jul 27, 2004 7:43 am Posts: 3
|
I use a file xml to question a table :
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.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" not-null="true"/>
<property name="filePath" type="string" not-null="true"/>
<property name="playTime" type="time">
<meta attribute="field-description">Playing time</meta>
</property>
<set name="artists" table="TRACK_ARTISTS" lazy="true">
<key column="TRACK_ID"/>
<many-to-many class="com.oreilly.hh.Artist" column="ARTIST_ID"/>
</set>
<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>
<set name="comments" table="TRACK_COMMENTS">
<key column="TRACK_ID"/>
<element column="COMMENT" type="string"/>
</set>
<list name="tracks" table="ALBUM_TRACKS">
<key column="ALBUM_ID"/>
<index column="POSIT"/>
<many-to-many class="com.oreilly.hh.Track" column="TRACK_ID"/>
</list>
</class>
<query name="com.oreilly.hh.tracksNoLongerThan"><![CDATA[
from com.oreilly.hh.Track as track
where track.playTime <= :length
]]></query>
<query name="com.oreilly.hh.tracksNoLongerThan2"><![CDATA[
select track.title from com.oreilly.hh.Track as track
where track.playTime <= :length
]]></query>
</hibernate-mapping>
but when I use the request "com.oreilly.hh.tracksNoLongerThan" with the code :
Query query = session.getNamedQuery("com.oreilly.hh.tracksNoLongerThan");
query.setTime("length", length);
return query.list();
it turns over me a list taking again all the recordings of the table without holding account of the criterion. The criterion "length" is well of the same type of the fields of the table
Could you help me[code][/code]
|
|