有个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,怎么这么写呢,是什么意思呢?
<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,怎么这么写呢,是什么意思呢?
解决方案 »
- 在web上实现拍照和录音
- 如何使用Teamwork License.jar 生成License
- 怎样实现正确登录
- 调查:JPA还是Hibernate
- 我这样写的查询语句不对吗?
- 用过JSTL中的SQL标签的朋友来看看~!
- 各位高手帮帮忙!~
- 在哪里下载isapi_redirect.dll
- tomcat4.01+apache2.046组合问题:单个的都能运行,...可以加分..
- 这个报错要怎么解决,感谢各位大神org.osoa.sca.ServiceRuntimeException: java.lang.reflect.Invocati
- 关于session和servlet的一个问题
- 即时通讯工具的问题!
还有数量和价格要连接商品这张表
要通过orderid和productid
对不起,改个错误,在这句中:明明在表中的字段是bookid,怎么这么写呢,是什么意思呢?把 bookid改为productid
一辆车里有一个唯一的编号idmanay-to-one故名思义-->多对一,也就是说多辆车会有同一种商品,反过来..一种商品可以被好多的车来买...怎么标识这种书,就是通过车里的productid知道这种商品,表里的关系应该这样
table ShopCart里的记录:
id productid
--------------------------
1 1
2 1
3 1三辆车里商品的编号都是1