2016-11-25 29 views
0

我得到这个could not resolve property: cart_id of: pojos.Cart异常,当我运行我的项目。我在Netbeans中使用了休眠。我使用Netbeans向导删除并重新添加了几次Hibernate,但无法工作。我该如何解决这个问题?谢谢。Java Hibernate错误:无法解析属性:cart_id:pojos.Cart

这里是我的映射文件,

Cart.hbm.xml

<hibernate-mapping> 
<class name="pojos.Cart" table="cart" catalog="design"> 
    <id name="cartId" type="java.lang.Integer"> 
     <column name="cart_id" /> 
     <generator class="identity" /> 
    </id> 
    <property name="date" type="string"> 
     <column name="date" length="10" /> 
    </property> 
    <property name="total" type="java.lang.Double"> 
     <column name="total" precision="22" scale="0" /> 
    </property> 
    <set name="userses" table="users" inverse="true" lazy="true" fetch="select"> 
     <key> 
      <column name="cart_id" not-null="true" /> 
     </key> 
     <one-to-many class="pojos.Users" /> 
    </set> 
    <set name="cartRegisters" table="cart_register" inverse="true" lazy="true" fetch="select"> 
     <key> 
      <column name="cart_id" not-null="true" /> 
     </key> 
     <one-to-many class="pojos.CartRegister" /> 
    </set> 
</class> 
</hibernate-mapping> 

编辑

Cart.java

package pojos; 
// Generated Nov 25, 2016 6:08:52 PM by Hibernate Tools 3.6.0 

import java.util.HashSet; 
import java.util.Set; 

public class Cart implements java.io.Serializable { 

    private Integer cartId; 
    private String date; 
    private Double total; 
    private Set userses = new HashSet(0); 
    private Set cartRegisters = new HashSet(0); 

    public Cart() { 
    } 

    public Cart(String date, Double total, Set userses, Set cartRegisters) { 
     this.date = date; 
     this.total = total; 
     this.userses = userses; 
     this.cartRegisters = cartRegisters; 
    } 

    public Integer getCartId() { 
     return this.cartId; 
    } 

    public void setCartId(Integer cartId) { 
     this.cartId = cartId; 
    } 

    public String getDate() { 
     return this.date; 
    } 

    public void setDate(String date) { 
     this.date = date; 
    } 

    public Double getTotal() { 
     return this.total; 
    } 

    public void setTotal(Double total) { 
     this.total = total; 
    } 

    public Set getUserses() { 
     return this.userses; 
    } 

    public void setUserses(Set userses) { 
     this.userses = userses; 
    } 

    public Set getCartRegisters() { 
     return this.cartRegisters; 
    } 

    public void setCartRegisters(Set cartRegisters) { 
     this.cartRegisters = cartRegisters; 
    } 
} 
+0

你能否提供类pojos.Cart? –

+0

@simas_ch:我发布pojos:购物车 – Malinda

+0

嗯。可以提供整个项目吗?也许在github上? –

回答

0

这不是映射。这是cartModal方法getMaxCart()中的查询:

cr.setProjection(Projections.max("cart_id")); 
+0

是的,但是这段代码有什么问题,我在其他文件中使用了这种方法,它在工作吗? – Malinda

+0

它应该是cartId –

相关问题