title: ids for this class must be manually assigned before calling save() hibernate 4.3
body: <p>I am trying to save data in table using hibernate. My entity looks like </p>
  
  <pre><code>@Entity
  public class Nemocnica  implements java.io.Serializable {
  
           @Id 
           @GeneratedValue(strategy=GenerationType.IDENTITY)
           //@Column(name="N_ID")
           private BigDecimal NId;
           private String adresa;
           private Set sanitkas = new HashSet(0);
  
          public Nemocnica() {
          }
  
  
          public Nemocnica( String adresa) {
              this.NId = NId;
          }
  
          public Nemocnica(BigDecimal NId, String adresa) {
              this.NId = NId;
              this.adresa = adresa;
          }
          public Nemocnica(BigDecimal NId, String adresa, Set sanitkas) {
             this.NId = NId;
             this.adresa = adresa;
             this.sanitkas = sanitkas;
          }
  
          public BigDecimal getNId() {
              return this.NId;
          }
  
          public void setNId(BigDecimal NId) {
              this.NId = NId;
          }
          public String getAdresa() {
              return this.adresa;
          }
  
          public void setAdresa(String adresa) {
              this.adresa = adresa;
          }
          public Set getSanitkas() {
              return this.sanitkas;
          }
  
          public void setSanitkas(Set sanitkas) {
              this.sanitkas = sanitkas;
          }
      }
  </code></pre>
  
  <p>And the way i want to insert data into it </p>
  
  <pre><code>public static Integer addNemocnica( String adresa ){
        Integer ID = null;
        try{
           Nemocnica n  = new Nemocnica( adresa);
           ID = (Integer) session.save(n); 
           tx.commit();
        }catch (HibernateException e) {
           if (tx!=null) tx.rollback();
           e.printStackTrace(); 
        }
        return ID;
     }
  </code></pre>
  
  <p>Yet it still throws error </p>
  
  <blockquote>
    <p>ids for this class must be manually assigned before calling save()</p>
  </blockquote>
  
  <p>I tried everything i found including</p>
  
  <pre><code>@GeneratedValue(strategy=GenerationType.IDENTITY)
  </code></pre>
  
  <p>I am using oracle database and the table i am trying to insert data into has set autoincrement to true. How can fix this?</p>
  
  <p>Thanks for help</p>