title: org.postgresql.util.PSQLException : ERROR : relation does NOT exist PreparedStatement.executeQuery ()
body: <p>For some strange reason hibernate generated query not working with postgres, it tells it cannot find relation/table even though there is valid table <code>film_actor</code> in <code>dvdrental</code> schema? This <a href="https://stackoverflow.com/questions/31506805/org-postgresql-util-psqlexception-error-relation-app-user-does-not-exist">answer</a> did not help.</p>
  
  <p><strong>Exception:</strong></p>
  
  <pre><code>org.postgresql.util.PSQLException : ERROR : relation "dvdrental.film_actor" does NOT exist PreparedStatement.executeQuery () FAILED ! 
  </code></pre>
  
  <p><strong>HQL</strong></p>
  
  <pre><code>Query searchQuery = session.createQuery("select film from Film as film " +
                      "inner join film.actors  as a " +
                      "inner join film.categories as c " +
                      "where c.categoryId=:categoryId " +
                      "and film.language.id=:languageId " +
                      "and film.releaseYear=:releaseYear " +
                      "and a.actorId=:actorId");
  </code></pre>
  
  <p><strong>Generated SQL</strong></p>
  
  <pre><code>SELECT
      film0_.film_id AS film_id1_8_,
      film0_.description AS descript2_8_,
      film0_.language_id AS languag12_8_,
      film0_.last_update AS last_upd3_8_,
      film0_. LENGTH AS length4_8_,
      film0_.rating AS rating5_8_,
      film0_.release_year AS release_6_8_,
      film0_.rental_duration AS rental_d7_8_,
      film0_.rental_rate AS rental_r8_8_,
      film0_.replacement_cost AS replacem9_8_,
      film0_.special_features AS special10_8_,
      film0_.title AS title11_8_
  FROM
      dvdrental. PUBLIC .film film0_
  INNER JOIN dvdrental.film_actor actors1_ ON film0_.film_id = actors1_.film_id
  INNER JOIN dvdrental. PUBLIC .actor actor2_ ON actors1_.actor_id = actor2_.actor_id
  INNER JOIN dvdrental.film_category categories3_ ON film0_.film_id = categories3_.film_id
  INNER JOIN dvdrental. PUBLIC .category category4_ ON categories3_.category_id = category4_.category_id
  WHERE
      category4_.category_id = 1
  AND film0_.language_id = 1
  AND film0_.release_year = 2016
  AND actor2_.actor_id = 2;
  </code></pre>
  
  <p><strong>This query works fine:</strong></p>
  
  <pre><code>SELECT
      *
  FROM
  film f
  INNER JOIN film_actor fa ON f.film_id = fa.film_id
  LIMIT 100;
  </code></pre>
  
  <p>The Film entity annotation based mapping:</p>
  
  <pre><code>@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
      @JoinTable(name = "film_actor", catalog = "dvdrental", joinColumns = {
              @JoinColumn(name = "film_id", nullable = false, updatable = false) },
              inverseJoinColumns = { @JoinColumn(name = "actor_id",
                      nullable = false, updatable = false) })
      public Set&lt;Actor&gt; getActors() {
          return actors;
      }
  
      public void setActors(Set&lt;Actor&gt; actors) {
          this.actors = actors;
      }
  </code></pre>
  
  <p><strong>Solution/Hack:</strong></p>
  
  <p>After commenting <code>/*catalog = "dvdrental"*/</code> the problem went away.</p>