title: Objects are not being persisted while using Hibernate(3.2.5) with PostgreSQL(8.2)
body: <p>I am using PostgreSQL(8.2) with Hibernate(3.2.5). Despite of proper annotations when I try to run my snippet at the back end, primary keys are not generated so it ends up with no record being inserted in the table.</p>
  
  <p>I am trying to establish One-To-Many mapping between the tables Classroom (One side) and Student (Many side). Please find my snippet below:</p>
  
  <p><strong>Classroom</strong> class</p>
  
  <pre><code>@Entity
  public class Classroom implements Serializable {  
      private static final long serialVersionUID = 1L;  
  
      @Id  
      @GeneratedValue(strategy = GenerationType.AUTO)  
      @Column(name="room_id")  
      private Long id;  
  
      @Column(name="Standard")  
      private String std;  
  
      @OneToMany(cascade=CascadeType.ALL)  
      @JoinColumn(name="room_id")  
      private Set&lt;Student&gt; students = new HashSet&lt;Student&gt;();  
  
     // with setters and getters
  }
  </code></pre>
  
  <p><strong>Student</strong> class  </p>
  
  <pre><code>@Entity  
  public class Student implements Serializable {  
      private static final long serialVersionUID = 1L; 
  
      @Id  
      @GeneratedValue(strategy = GenerationType.AUTO)  
      @Column(name="roll_no")  
      private Long id;    
  
      @Column(name="name")  
      private String name; 
  
     // with setters and getters
  }
  </code></pre>
  
  <p><strong>Main</strong> class  </p>
  
  <pre><code>public class Main {
  
      public static void main(String arr[]){
          EntityManagerFactory emf = Persistence.createEntityManagerFactory("OneTomanyMyDbPU");
          EntityManager em = emf.createEntityManager();
  
          Set&lt;Student&gt; students = new HashSet&lt;Student&gt;();
  
          Classroom c = new Classroom();
  
          Student s1 = new Student();
          Student s2 = new Student();
  
          s1.setName("abc");
          s2.setName("xyz");
  
          students.add(s1);
          students.add(s2);
  
          c.setStd("X");
          c.setStudents(students);
  
          try {
              EntityTransaction tr = em.getTransaction();
  
              System.out.println("Classroom b4 persisting...:"+c.getStd());
              em.persist(c);
  
              tr.commit();
          } catch(Exception e){
          }
      }
  }
  </code></pre>
  
  <p><strong>persistence.xml</strong>  </p>
  
  <pre><code>&lt;persistence-unit name="OneTomanyMyDbPU" transaction-type="RESOURCE_LOCAL"&gt;
      &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
      &lt;class&gt; model.Classroom&lt;/class&gt;
      &lt;class&gt; model.Student&lt;/class&gt;
      &lt;properties&gt;
          &lt;property name="hibernate.connection.username" value="postgres"/&gt;
          &lt;property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/&gt;
          &lt;property name="hibernate.connection.password" value="abc123"/&gt;
          &lt;property name="hibernate.connection.url" value="jdbc:postgresql://localhost/mydb"/&gt;
          &lt;property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/&gt;
          &lt;property name="hibernate.hbm2ddl.auto" value="update"/&gt;
      &lt;/properties&gt;
  &lt;/persistence-unit&gt;
  </code></pre>
  
  <p></p>
  
  <p>What can be the cause? How to persist them?</p>