CREATE TABLE ratecodes
(
roomId
int (11) NOT NULL ПО УМОЛЧАНИЮ '0',
date
date NOT NULL DEFAULT '0000-00-00',
..., ПЕРВИЧНЫЙ КЛЮЧ (roomId
, date
))
hbm.xml
<class catalog="hermes" name="com.hermes.data.RateCode" table="ratecodes">
<composite-id class="com.hermes.data.RateCodeId" name="id">
<key-property name="roomId" type="int">
<column name="roomId"/>
</key-property>
<key-property name="date" type="date">
<column length="10" name="date"/>
</key-property>
</composite-id>
<version name="version" type="java.lang.Long">
<column name="version" precision="10" scale="0"/>
</version>
я хочу запросить
HibernateUtil.getCurrentSession (). CreateQuery ("из RateCode где (RatecodeId (Между | <) RateCodeId)" </p>
SQL:
"из RateCode, где roomId = 3000 и дата>: fromDate и дата <: toDate" </p>
RatecodeId.java (составной)
public class RateCodeId implements java.io.Serializable {
private int roomId;
private Date date;
public RateCodeId() {
}
public RateCodeId(int roomId, Date date) {
this.roomId = roomId;
this.date = date;
}
public int getRoomId() {
return this.roomId;
}
public void setRoomId(int roomId) {
this.roomId = roomId;
}
public Date getDate() {
return this.date;
}
public void setDate(Date date) {
this.date = date;
}
public boolean equals(Object other) {
if ((this == other)) {
return true;
}
if ((other == null)) {
return false;
}
if (!(other instanceof RateCodeId)) {
return false;
}
RateCodeId castOther = (RateCodeId) other;
return (this.getRoomId() == castOther.getRoomId())
&& ((this.getDate() == castOther.getDate()) || (this.getDate() != null && castOther.getDate() != null && this.getDate().equals(castOther.getDate())));
}
public int hashCode() {
int result = 17;
result = 37 * result + this.getRoomId();
result = 37 * result + (getDate() == null ? 0 : this.getDate().hashCode());
return result;
}
}
как установить FromDate и Todate в Object и выполнить условие RateCodeID