Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPQL check if collection member has attribute with required value

I have entity (e.g. Setting) which contains collection (e.g. Settings.languages) with another objects (instances of Language).

Is there way how to select all entities which contains in its collection entity with required attribute value? e.g. get all Settings which Settings.languages contains Language.code = 'EN' ?

Something like:

 SELECT s FROM Setting s WHERE :code MEMBER OF s.languages.code
like image 408
Fenix Avatar asked Oct 22 '25 06:10

Fenix


1 Answers

You can use something like this:

SELECT s FROM Setting s INNER JOIN s.languages c WHERE c = :code

More examples was here

like image 197
r0101 Avatar answered Oct 27 '25 05:10

r0101



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!