我收到此错误
menu_categories is not mapped [from menu_categories]
我的休眠电话是
public List loadMenuCategories(SessionFactory sessionFactory){
List types = new ArrayList<MenuCategories>();
Session session = sessionFactory.getCurrentSession();
session.beginTransaction();
Query query = session.createQuery("from menu_categories");
List result = query.list();
Iterator it = result.iterator();
while(it.hasNext()){
MenuCategories menuCategories = (MenuCategories)it.next();
types.add(menuCategories);
}
sessionFactory.close();
return types;
}
我的豆子是
@Entity
@Table(appliesTo = "menu_categories")
public class MenuCategories extends BaseModel{
/**
*
*/
private static final long serialVersionUID = -4875305890823765933L;
}
package com.rizstien.myhotel.framework.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import org.apache.commons.lang.StringUtils;
public class BaseModel implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "id", nullable=false)
private Integer id;
@Column(name = "name")
private String name;
@Column(name = "description")
private String desc;
@Column(name = "is_active")
private boolean active;
@Column(name = "no_of_items")
private Integer noOfItems;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
if (!StringUtils.isEmpty(name)) {
this.name = name;
}
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
if (!StringUtils.isEmpty(desc)) {
this.desc = desc;
}
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public Integer getNoOfItems() {
return noOfItems;
}
public void setNoOfItems(Integer noOfItems) {
this.noOfItems = noOfItems;
}
}
编辑 这是我的休眠配置文件
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3311/myhotel</property>
<property name="hibernate.connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.pool_size">5</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="current_session_context_class">thread</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<mapping class="com.rizstien.myhotel.menucategories.model.MenuCategories"/>
</session-factory>