JPA and many-to-many relations in google app engine

后端 未结 1 1646
不知归路
不知归路 2021-01-22 14:32

I have entities A and B, and A can have set of B. The same instance of B can belong to several A. So there is classical many-to-many relation here.

In GAE there is no di

相关标签:
1条回答
  • 2021-01-22 15:33

    If you refactor your relationship mapping you can get a better query. Instead of storing a set of keys in A, store a set of keys in B. Then you can query with

    select * from B where a_id = {idOfRelevantA} and property0 = {criterion0} and property1 = {criterion1}...
    

    This way you avoid the multiple queries that the in operator creates.

    Also, beware: in will only work for a list of 30 elements or fewer.

    0 讨论(0)
提交回复
热议问题