Я использую спящий режим.Я использую данный запрос для извлечения информации из db
Query q = session.createQuery("select m.menuId,m.menuType,it.itemId,it.name,it.price,it.currency," +
"ingr.ingredientId,ingr.ingredient from Menu as m, MenuItem as it," +
"KeyIngredient as ingr where m.menuId in "+
"(select MenuId from MenuItem as itm innerjoin KeyIngredient as ing "+
"where itm.itemId = ing.MenuItemId) and m.RestaurantId=" +restaurantId);
, когда я запускаю этот запрос, я получаю эту ошибку
could not resolve property: menuId of: com.hibernate.model.Menu [select m.menuId,m.menuType,it.itemId,it.name,it.price,it.currency,ingr.ingredientId,ingr.ingredient
from com.hibernate.model.Menu as m, com.hibernate.model.MenuItem as it,com.hibernate.model.KeyIngredient as ingr where m.menuId in (select MenuId from
com.hibernate.model.MenuItem as itm innerjoin KeyIngredient as ing where itm.itemId =
ing.MenuItemId) and m.RestaurantId=1]
Это файл menu.hbm.xml
<hibernate-mapping>
<class name="com.hibernate.model.Menu" table="Menu" catalog="mydb">
<composite-id name="id" class="com.hibernate.model.MenuId">
<key-property name="menuId" type="int">
<column name="menu_id" />
</key-property>
<key-property name="restaurantId" type="long">
<column name="Restaurant_id" />
</key-property>
<key-property name="menuType" type="string">
<column name="menuType" length="45" />
</key-property>
</composite-id>
</class>
</hibernate-mapping>
Класс меню
public class Menu implements java.io.Serializable {
private MenuId id;
public Menu() {
}
public Menu(MenuId id) {
this.id = id;
}
public MenuId getId() {
return this.id;
}
public void setId(MenuId id) {
this.id = id;
}
}
Класс MenuId
public class MenuId implements java.io.Serializable {
private int menuId;
private long restaurantId;
private String menuType;
public MenuId() {
}
public MenuId(int menuId, long restaurantId, String menuType) {
this.menuId = menuId;
this.restaurantId = restaurantId;
this.menuType = menuType;
}
public int getMenuId() {
return this.menuId;
}
public void setMenuId(int menuId) {
this.menuId = menuId;
}
public long getRestaurantId() {
return this.restaurantId;
}
public void setRestaurantId(long restaurantId) {
this.restaurantId = restaurantId;
}
public String getMenuType() {
return this.menuType;
}
public void setMenuType(String menuType) {
this.menuType = menuType;
}
public boolean equals(Object other) {
if ((this == other))
return true;
if ((other == null))
return false;
if (!(other instanceof MenuId))
return false;
MenuId castOther = (MenuId) other;
return (this.getMenuId() == castOther.getMenuId())
&& (this.getRestaurantId() == castOther.getRestaurantId())
&& ((this.getMenuType() == castOther.getMenuType()) || (this
.getMenuType() != null
&& castOther.getMenuType() != null && this
.getMenuType().equals(castOther.getMenuType())));
}
public int hashCode() {
int result = 17;
result = 37 * result + this.getMenuId();
result = 37 * result + (int) this.getRestaurantId();
result = 37 * result
+ (getMenuType() == null ? 0 : this.getMenuType().hashCode());
return result;
}
}
и это моя запись в файле cfg
<mapping resource="com/hibernate/model/Menu.hbm.xml"/>
Как я могусделать это правильно?Спасибо