title: How does Hibernate create query? How to Avoid reaching limit of 61 table?
body: <p>I have a Java Class X which is actually an Entity that is connected to Spring Data JPA. 
  It has annotation: @Entity (javax.persistence.Entity)</p>
  
  <p>Lately, we have added a column/member to this class, and that caused that when this class is fetched from database with Spring DataJPA (I'm not quite sure how to call it), I get the known error: </p>
  
  <blockquote>
    <p>Exception: Too many tables; MariaDB can only use 61 tables in a join - could not extract ResultSet</p>
  </blockquote>
  
  <p>I don't need so many joins, I simply understood that JPA creates many joins to be on the safer side.</p>
  
  <p>My question is: 
  How do I minimize my class to make wisely in a way that tere would be less joins?</p>
  
  <p>I went over the members of my Class X,</p>
  
  <p>and found there were 25 fields which connect to other "class-Entity tables".</p>
  
  <p>Some are of OneToMany relationship and some of ManyToOne.</p>
  
  <p>So that's not 61.</p>
  
  <p>I noticed that the above error was roused when trying to fetch other entity-class Y, that two of it's members are of type X.</p>
  
  <p>I tried minimizing one of the members of entity-class X, but it didn't help.</p>
  
  <p>So that's my other question included:
  How does JPA create it's auto generated query (as explained <a href="https://docs.spring.io/spring-data/jpa/docs/1.11.0.M1/reference/html/#jpa.query-methods.query-creation" rel="nofollow noreferrer">here</a>)?
  Understanding this will make things much clearer and simpler for me to avoid this error, tackle the error if it shows, and more important - to organize my class entities more efficiently.</p>
  
  <p>Thank-you!</p>