EJB3 - 处理非标准链接表
我遇到的情况是使用 EJB3 和遗留数据库。 我有一种情况,两个表 A 和 B 之间存在多对多关系,通过第三个(链接)表 L 定义。
复杂的是,链接表中除了表 A 的 PK 之外还有其他字段B. 这些列是标准时间戳和用户列,用于记录谁生成了链接。 这两个附加列阻止我使用连接表注释定义多对多关系,因为它们不可为空,因此必须填充。
有谁知道解决这个限制的方法吗? 我可以定义从链接表到关系中每个其他表的一对多关系,但这不是很优雅。
谢谢,
I have a situation where I am working with EJB3 and a legacy database. I have a situation where there is a many-to-many relationship between two tables A and B, defined through a third (link) table L.
The complication is that the link table has other fields in it other than the PK's of tables A and B. The columns are standard timestamp and user columns to record who generated the link. These two additional columns are preventing me from defining the many-many relationship using a join table annotation, as they are not nillable and so must be populated.
Does anyone know of a way around this limitation? I could define One-to-many relationships from the link table to each of the other tables in the relationship, but this is not very elegant.
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,是的,但你需要让它变得优雅。 以下超类可用于将任意多对多关系定义为实体:
基于该超类的实体示例(片段):
Yes, it is but you need to make it elegant. The following super-class can be used to define arbitrary many-to-many relationship as an entity:
The example of entity based on this super class (fragment):