有个Hibernate映射文件,其中有个小问题。我看不懂,哪位好人帮我解释一下,真的谢谢了!
  <class name="cn.com.shoppingonline.ShopCart" 
            table="shopcart"
            discriminator-value="C">
                
        <id name="id">
               <generator class="increment"/>
        </id>     <property name="orderid"/>
    <many-to-one name="product" class="Product" column="productid"/>
        <property name="count"/>
        <property name="price"/>
</class>
就是这句看不懂:<many-to-one name="product" class="Product" column="productid"/>明明在表中的字段是bookid,怎么这么写呢,是什么意思呢?

解决方案 »

  1.   

    也就是说一张商店的进货表递增的id多个id针对一件商品(也就是一个商品可以有多个id)
    还有数量和价格要连接商品这张表
    要通过orderid和productid
      

  2.   

    非常感谢你!
    对不起,改个错误,在这句中:明明在表中的字段是bookid,怎么这么写呢,是什么意思呢?把 bookid改为productid
      

  3.   

    有点不一样的见解:
    一辆车里有一个唯一的编号idmanay-to-one故名思义-->多对一,也就是说多辆车会有同一种商品,反过来..一种商品可以被好多的车来买...怎么标识这种书,就是通过车里的productid知道这种商品,表里的关系应该这样
    table ShopCart里的记录:
    id      productid
    --------------------------
    1        1
    2        1
    3        1三辆车里商品的编号都是1