如何使用 JPA 1.0 执行非多态 JPQL 查询?
想象我有 3 个实体,Basic
<- Sub
<- SubSub
。我想选择 Basic
和 Sub
但不是 SubSub
我已经发现在 JPA 2.0 中我可以进行此查询 从 Basic b WHERE TYPE(b) IN (Basic,Sub) 中选择 b
但我必须使用的实现是apache-openjpa-1.2.3-SNAPSHOT。
如何使用 JPA 1.0 完成任务?我对任何事情都持开放态度。我可以查询鉴别器列(普通 SQL 或 JPQL)吗?有某种查询提示吗?可以通过不使用继承而是使用某种组合来解决吗?
我很感激你的帮助。谢谢
imagine i have 3 Entities, Basic
<- Sub
<- SubSub
. I want to select Basic
and Sub
but not SubSub
I have already discovered that in JPA 2.0 I can have this querySELECT b FROM Basic b WHERE TYPE(b) IN (Basic,Sub)
But the implementation I have to work with is apache-openjpa-1.2.3-SNAPSHOT.
How can I accomplish the task with JPA 1.0? I'm open for anything. Can I query for the Discriminator Column (plain SQL or JPQL)? Is there some kind of queryHint? Can it be solved by not using Inheritance but some sort of Composition?
I'd appreciate your help. thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有测试,但我认为你需要类似的东西:
I didn't test, but I think that you need something similar to this: