0

I have table Events

 |  EVENT_ID   |   OTHER    |
 ----------------------------
 |             |            |
 |             |            |
 |             |            |

and table EventCategories that contains foreign key for Event table:

 |  TABLE_ID   |  EVENT_ID  |
 ----------------------------
 |             |            |
 |             |            |
 |             |            |

I need all EVENT_ID that are within Events table but are not in EventCategories table.

    SELECT EVENT_ID FROM Events
    WHERE EVENT_ID NOT IN 
        (
          SELECT DISTINCT EVENT_ID 
          FROM EventCategories
        )

How can I write criteria query ?

delux
  • 1,694
  • 10
  • 33
  • 64

1 Answers1

0

You should probably edit your question to say what you have tried.

You want a predicate to test for Events with an empty EventCategory collection. In JPQL it would look something like this

select e from Event e where e.categories is empty
carbontax
  • 2,164
  • 23
  • 37