JPA/Hibernate maximum number of joins?

后端 未结 5 1753
面向向阳花
面向向阳花 2021-01-14 15:42

Is there a limit to the number of joins permitted in a JPA/Hibernate query?

Since Hibernate doesn\'t automatically join, I have to explicitly specify the joins in my

相关标签:
5条回答
  • 2021-01-14 16:03

    I've once hit the MySQL 5.0 61 table limit with Hibernate:

    ERROR 1116 (HY000): Too many tables; MySQL can only use 61 tables in a join
    0 讨论(0)
  • 2021-01-14 16:08

    Are you aliasing all of your inner joins? And using those aliases? I have seen some really strange behavior with Hibernate when you try and use implicit aliasing in the SELECT clause to do stuff like this (extremely simplified example):

    select p.address.state from person p
    

    But if you explicitly declare all your aliases it works just fine. Like this:

    select s from person p join p.address a join a.state s
    

    ... or even this:

    select s from person p join p.address.state s
    
    0 讨论(0)
  • 2021-01-14 16:09

    The question is why are you trying to make such a complex query in the first place?

    Have you considered different approaches? The documentation on improving performance makes some suggestions.

    0 讨论(0)
  • 2021-01-14 16:15

    There is nothing within the Hibernate code which limits the number of joins. This could be a bug in the dialect, or a limitation of the database engine. But my money's on a bug unrelated to the number of joins! Have you tried running the SQL directly in an interactive query session?

    0 讨论(0)
  • 2021-01-14 16:24

    Have you tried to execute with the actual jdbc driver in use? It might be a issue of the jdbc driver.

    Although judging from the name of the column, it is looking for, I'd guess there is some trimming/construction of names going wrong. Definitely looks more like a bug than a intended limit.

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