java - one 2 many jpa qry with join -


i trying use jpa join qry 1 many entities

entity table unit (one) entity table appartment (many)

i using following jpa

@query("select u unit u inner join u.appartmentlist " +         "where u.unitnumber in :unitnumbers " +         "and a.appnumber= :appnumber") page findapt(@param("unitnumbers") collection<string> unitnumbers,                @param("appnumber") integer appnumber,                pageable pageable);enter code here 

i need able 2 appartments (one in each unit passed unita,unitb).
if ../findstuff?unitnumbers=unita,unitb&appnumber=1

but appartments in each unit instead, not appnumber=1 in each unit.

any idea on how achieve appreciated

thank you

you need query on appartment.

@query("select appartment where" +  " a.appnumber= :appnumber , a.unit.unitnumber in :unitnumbers" 

if unit lazy fetched, may want fetch first query, query becomes:

@query("select appartment join fetch a.unit where" +      " a.appnumber= :appnumber , a.unit.unitnumber in :unitnumbers" 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -