[英]org.hibernate.hql.ast.QuerySyntaxException
i get this exception when i was running an application please give me a solution 运行应用程序时出现此异常,请给我一个解决方案
in my mapping file like as follows: 在我的映射文件中,如下所示:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="mobilserv.bo.SalesanalyzerBean" table="sales_analyzer">
<id name="id" access="field" type="long" column="ID">
<generator class="native" />
</id>
<property name="name" access="field" column="name" />
<property name="itemname" access="field" column="itemname" />
<property name="total_qty" access="field" column="Total_qty" />
<property name="amount" access="field" column="Total_amount" />
</class>
</hibernate-mapping>
And my entity: 而我的实体:
package mobilserv.bo;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Entity;
@Entity
@Table(name = "sales_analyzer")
public class SalesanalyzerBean {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
private String itemname;
protected int total_qty;
private double amount;
@ManyToOne(fetch=FetchType.LAZY,cascade = CascadeType.ALL)
protected MenuItemBean item;
@OneToMany(fetch=FetchType.LAZY,mappedBy = "order", cascade = CascadeType.ALL)
protected List<OrderItemBean> orderItems;
protected List<CategoryBean> categery;
public List<CategoryBean> getCategery() {
return categery;
}
public void setCategery(List<CategoryBean> categery) {
this.categery = categery;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getItemname() {
return itemname;
}
public void setItemname(String itemname) {
this.itemname = itemname;
}
public int getTotal_qty() {
return total_qty;
}
public void setTotal_qty(int total_qty) {
this.total_qty = total_qty;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public MenuItemBean getItem() {
return item;
}
public void setItem(MenuItemBean item) {
this.item = item;
}
public List<OrderItemBean> getOrderItems() {
return orderItems;
}
public void setOrderItems(List<OrderItemBean> orderItems) {
this.orderItems = orderItems;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
You need to show more and to clarify a few things, what you're currently showing is pretty confusing. 您需要显示更多并澄清一些事情,当前显示的内容非常令人困惑。
hbm.xml
mapping file and annotations. hbm.xml
映射文件和注释。 They're basically doing the same thing (providing metadata to map an entity) but they're exclusive. hbm.xml
is incomplete (it doesn't map the associations). hbm.xml
是不完整的(它没有映射关联)。 If you're using it, it might not give the expected results. AnnotationConfiguration
and how your SalesanalyzerBean
is declared in your hibernate.cfg.xml
AnnotationConfiguration
以及如何在hibernate.cfg.xml
声明SalesanalyzerBean
可能实际上很有趣。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.