title: PostgreSql does not "recognize" table created by Hibernate
body: <p>I have problem to create two associated tables with hibernate in a PostgreSQL database. I am inclined to believe that the problem lies in the Database (configuration?) since I have tried nearly all the Hibernate approaches proposed in Internet sites and I receive still the same error. Is there any configuration demanded before using a PostgreSql database? I cannot explain in other way the error which appears:</p>
  
  <p>"Relation department does not exist"</p>
  
  <p>I Join the two Entities Employee and Department as follows:</p>
  
  <pre><code>@Entity
  @Table(name="EMPLOYEE")
  public class Employee implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name="employee_id")
  private Long employeeId;
  .
  .
  .
  
  @ManyToOne
  @JoinColumn(name="department_id")
  public Department getDepartment() {
      return department;
  }
  
  public void setDepartment(Department department) {
      this.department = department;
  }
  
  private Department department; 
  </code></pre>
  
  <p>And</p>
  
  <pre><code>@Entity
  @Table(name="DEPARTMENT")
  public class Department implements Serializable {
  
  private static final long serialVersionUID = 1L;
  
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name="DEPARTMENT_ID")
  private Long departmentId;
  
  .
  .
  .
  @OneToMany(mappedBy="department")
  public Set&lt;Employee&gt; getEmployees() {
      return employees;
  }
  
  public void setEmployees(Set&lt;Employee&gt; employees) {
      this.employees = employees;
  }
  
  
  private Set&lt;Employee&gt; employees;
  </code></pre>
  
  <p>I am trying to create the tables with a couple of records in the main method as:</p>
  
  <pre><code>SessionFactory sf = new Configuration().configure().buildSessionFactory();
          Session session = sf.openSession();
          session.beginTransaction();
  
          Department department = new Department();
          department.setDepartmentName("Sales");
          session.persist(department);
  
          Employee emp1 = new Employee("Nina", "Mayers", "111");
          Employee emp2 = new Employee("Tony", "Almeida", "222");
  
          emp1.setDepartment(department);
          emp2.setDepartment(department);
  
          session.persist(emp1);
          session.persist(emp2);
  
          session.getTransaction().commit();
          session.close();
  </code></pre>
  
  <p>The error comes up on the line : <code>session.persist(department);</code></p>
  
  <p>Is anyone experienced in PostgreSql Databases, to help me to find why it cannot recognize the tables/relations and it comes up with the error:</p>
  
  <p>"Relation department does not exist"  ?</p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>I have looked at the log file. After the usual message coming out from Eclipse as well, the last line of the message is: "No connection could be made because the target machine actively refused it". I deduce that the problem is probably at the connection. Are there any properties, which I should set (in pgAdmin) in order to achieve the connection? I have set the line </p>
  
  <p><code>&lt;property name="hibernate.connection.url"&gt;jdbc:postgresql://localhost:5432/testDB&lt;/property&gt;</code> in cfg.xml file in Eclipse.</p>