Halo Deng
Halo Deng

Reputation: 3

SpringData JPA left join SubQuery

select sm.* 
from   system_mail sm 
left join (SELECT u.mail_code 
           from   user_mail u 
           where u.to_user = 1 ) um 
on sm.mail_id = um.mail_code 
where um.id is null.

this SQL was running well in mysql but wrong in SpringData JPA,how can i use it in springdata jpa?enter image description here

Upvotes: 0

Views: 302

Answers (1)

kiks73
kiks73

Reputation: 3758

You should try to force using the DB Engine to run your SQL with nativeQuery = true:

@Query(nativeQuery = true, value="...yourqueryhere...")

Upvotes: 1

Related Questions