简体   繁体   English

JPA标准API:如何使用IN关键字并查询另一个谓词的结果?

[英]JPA criteria API: How to use IN keyword and query the result for another predicate?

Sorry for the bad title, I don't really know how to word it better: 对不起,标题不好,我真的不知道怎么写得更好:

I have the following tablestructure: 我有以下表格结构:

Table A --> Table B  <-- Table C (proceeds) --> Table D(prcoeeding_status)
--------    --------     -------                -------
 aID         bID           cID                   dID
 ...         ....          created             textValue
 f_bID       ....          f_bID       
                           f_dID

meaning A and C have a foreign key pointing to B and C also has a foreign key pointing to D 意思是A和C的外键指向B,C的外键也指向D

I have a predicate like this (root being the Table A): 我有一个这样的谓词(根是表A):

constraintCondition = (TableA.join("Table B key")
                        .joinList("Table C Key")
                        .join("Table D Key").get("value from table D"))
                        .in(someValues);

This works fine and gives me the expected results. 这工作正常,并给了我预期的结果。 Now I need to add another constraint, selecting only entries where in Table C a date-entry (namely 'created') is between a Startdate and Enddate. 现在,我需要添加另一个约束,只选择表C中日期输入(即“创建”)在开始日期和结束日期之间的条目。 How do I chain another predicate to this predicate, or how do I need to modify this predicate, so that I will get the desired effect? 我如何将另一个谓词链接到该谓词,或者我需要如何修改此谓词,以便获得预期的效果?

EDIT: 编辑:

I got an answer to this question here: JPA 2 criteria API: How to select values from various joined tables without using Metamodel? 我在这里对此问题有一个答案: JPA 2条件API:如何在不使用Metamodel的情况下从各种联接表中选择值?

Please look here, it is the same problem, better described and answered: 请在这里查看,这是一个相同的问题,得到了更好的描述和回答:

JPA 2 criteria API: How to select values from various joined tables without using Metamodel? JPA 2标准API:如何在不使用Metamodel的情况下从各种联接表中选择值?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM