java - hibernate中的一对多关联

标签 java hibernate

hibernate文档给出了我们在Hibernate中使用一对多关联时的一些规则:

http://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/collections.html#collections-onetomany

A one-to-many association links the tables of two classes via a foreign key with no intervening collection table. This mapping loses certain semantics of normal Java collections:

  • An instance of the contained entity class cannot belong to more than one instance of the collection.
  • An instance of the contained entity class cannot appear at more than one value of the collection index.

请帮助我理解这些陈述。

假设我有一个产品并且它有零件集合,现在根据要点对我的产品及其零件应用了什么样的限制?

最佳答案

  • 一个部件不能属于 2 个或多个产品
  • 一个部件不能在产品部件集合中出现多次

关于java - hibernate中的一对多关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19757360/

相关文章:

Java-BankAccount.class

java.lang.IllegalArgumentException : org. hibernate.hql.internal.ast.QuerySyntaxException:用户未映射[来自用户]

java - Hibernate 持久化对象成员

java - java中如何将多个字符串解析为int

java - 调试与日历日期 GMT 相关的简单 java 代码

java - Apache Poi Word 文档打开报 NullPointerException

java - 当我使用 @IdClass LinkedHashSet 时包含重复的项目

java.sql.SQLException 无效的对象名称

java - 使用注释从 hibernate 中的其他表映射数据?

java - primefaces 数据表中的单选按钮和复选框