0

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

I have a predicate like this (root being the Table 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. 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?

Community
  • 1
  • 1
random_error
  • 365
  • 4
  • 16
  • Perhaps this link should help http://stackoverflow.com/questions/5594309/how-to-rewrite-this-query-using-jpa-criteria-query – smk Nov 02 '12 at 14:14
  • My problem is different from the one in the link presented: I have many tables that I need to join, but then I have to test against predicates concerning different tables. If I just chainlink predicates testing if the time of table C is between the correct values and then check if the value from table D is in the correct values, it will also give me results where the time is correct in table C, but for wrong values in table D – random_error Nov 07 '12 at 12:44

1 Answers1

0

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?

Community
  • 1
  • 1
random_error
  • 365
  • 4
  • 16