问题标签 [hibernate-onetomany]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - 无法在 HIbernate 4 中保持 OneToMany 关系
在获取一些数据时遇到问题,休眠时会持续存在
我声明了两个独立的类,License 和 MacAddress。MacAddress 可以单独存在,但也可以链接到许可证,当 hibernate 生成基础表时,它会创建许可证、MacAddress 和 License_MacAddress 表。
执照
MAC地址
我想要做的是以下。
在某个时候,会创建一个新许可证并在许可证表中存储一行(这可以正常工作)
然后在稍后的时间收到用户的许可证和 MAC 地址。从数据库中检索许可证,我们检查提供的 macAddress 是否已经与许可证相关联(多个 macaddress 可以与许可证相关联),如果没有,我们想要存储 macaddress 以及许可证和 macaddress 之间的链接。
但是,尽管在 License 的 @OneToMany 注释上设置了 CascadeType.ALL,但没有存储任何 Mac 地址信息。我可以通过单独保存该对象来手动保存 MacAddress,但 License_MacAddress 表仍然为空。
代码
为什么我不能把两者的关系坚持下去?
jpa-2.0 - hibernate jpa将两个表与另一个表连接起来
我有两张桌子A和B
表 A:
ID_A
姓名
表 B
ID_B
姓名
我通过带有主键的第三个表 C 表加入了这两个表
表 C
ID_C
ID_A
ID_B
我想知道 jpa 映射中的这种关系以检索对象 A 中的对象 B 的列表
谢谢你,
java - OneToMany/ManyToOne 关系的休眠条件
我在两个对象之间有 OneToMany/ManyToOne 关系,例如:
我想得到拥有company.companyName like xxxx%
. 我试过类似的东西:
但我得到错误:
这段代码的问题在哪里?
nhibernate - NHibernate CreateCriteria with Restrictions 无法按预期工作
下面给出的代码示例是检索所有活动记录。
父表 VesselMasterData 和子表是 BasicInfo 和 DimentionInfo。基于查询的预期值应该是 BasicInfo 和 DimentionInfo 的所有活动记录。
但在输出中,我从 BasicInfo 和 DimentionInfo 中获取所有记录。可能是什么问题。
这是 VesselMasterData 表的映射。
hibernate - TransientObjectException - 对象引用未保存的瞬态实例 - 在刷新之前保存瞬态实例
对于我的问题,我遇到了一些很好的答案,但这是关于从 Hibernate 3.4.0GA 升级到 Hibernate 4.1.8。所以这曾经在以前的版本下工作,我已经搜索了高低,为什么它会在这个新版本中中断。
我得到一个
org.hibernate.TransientObjectException:对象引用了未保存的瞬态实例 - 在刷新之前保存瞬态实例:com.test.server.domain.model.NoteItem.note -> com.test.server.domain.model.Note
任何帮助都会很棒。
这是我的课。
hibernate - 使用 Hibernate 删除一对多关系中的对象时 PostgreSQL 异常
我有非常简单的模式 - 一对多关系中的两个表:
保存和更新类型的对象CorrelationKey
可以正常工作,并且更改会传播到集合中。但是当我尝试删除一个CorrelationKey
对象时,我收到以下错误:
我在 Windows 机器上使用 PostgreSQL 9.1。
非常感谢。
hibernate - One to many association - Join tables with non primary key column in JPA
I'm working on legacy system, need to read some of the info from database. Below are the table relationship
Vendor (vendorId - pk, vendorEid, name)
VendorContactBridge (bridgeId -pk, vendorEid, contactEid)
Contact (contactId -pk, contactEid, phone)
vendorEid and contactEid are not the primary key of the table but used as join column in Join table VendorContactBridge.
Vendor Entity -
#xA;Contact Entity -
#xA;while running the query, getting below exception
SecondaryTable JoinColumn cannot reference a non primary key.
I removed the Eager fetch which i have given in Vendor entity, i dont get any exception but it doesn't load the collection. What's wrong with association ?
hibernate - 为什么hibernate为单向OneToMany创建一个连接表?
为什么hibernate对这些类使用连接表?
我既不想要连接表也不想要双向关联:(
hibernate - org.hibernate.AssertionFailure: null identifier with OneToMany/ManyToOne Relationship
I have a problem with a OneToMany/ManyToOne relationship:
Class Project:
Class Person:
Everything works fine as long as there is at least one person connected to a project in the database. If I create a new project and there is no person in the database I get an hibernate exception:
I already set nullable=true for the project class but this doesnt work. Ideas anyone?
hibernate - Hibernate OneToMany OrderBy 搞乱了主查询
我在 Hibernate 中有一个要查询的类 Video,并且我按Order.desc("id")
. 查询按预期工作。但是,如果我@OneToMany
在 Video 中添加注释以包含评论,我也会在@OrderBy
同一注释中添加一个(我需要评论是ordered by "createdTime"
)。
这打破了主要查询 - 视频的返回现在是错误的:它命令 SQL 首先返回没有评论的视频,然后是 1 条评论,等等:
我只需要按他们的 ID 对视频进行排序。