title: inserting new row in sqlite using hibernate
body: <p>Decide to use sqlite with hibernate.
  First of all this is only test  project.</p>
  
  <p>My entity classes</p>
  
  <p><strong>Address.java</strong></p>
  
  <pre><code>@Entity
  @Table(name = "ADDRESS")
  public class Address {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "ID", length = 3, nullable = false, unique = true)
      private Long id;
      @Column(name = "NAME", length = 40, nullable = false)
      private String name;
      @OneToMany(mappedBy = "address", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
      private Set&lt;Flat&gt; flats;
  </code></pre>
  
  <p><strong>Flat</strong></p>
  
  <pre><code>@Entity
  @Table(name="FLAT")
  public class Flat {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      @Column(name = "ID", length = 6, unique = true)
      private long id = 1L;
      @Column(name = "CRTN_DATE", nullable = false)
      private Date creationDate;
      @ManyToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
      @JoinColumn(name = "ADDRESS_ID", nullable = false)
      private Address address;
      @Column(name = "ROOM_CNT", length = 1)
      private int roomCount;
      @Column(name = "AREA", length = 4)
      private long totalArea;
      @Column(name = "PHONE", length = 1)
      private String phone;
      @Column(name = "PRICE", length = 7)
      private float price;
  </code></pre>
  
  <p>so my problem:
  When I try to insert new row like this </p>
  
  <pre><code>Flat flat = new Flat();
  flat.setTotalArea(45);
  flat.setCreationDate(new Date());
  flat.setAddress(addressDAO.getByID(3));
  flat.setRoomCount(2);
  flat.setPrice(68000);
  flat.setPhone("Y");
  flat.setImages(new HashSet&lt;ImageStorage&gt;());
  flatDAO.save(flat);
  </code></pre>
  
  <p>I get such output in my console:</p>
  
  <pre><code>Hibernate: insert into FLAT (ADDRESS_ID, CRTN_DATE, PHONE, PRICE, ROOM_CNT, AREA) values (?, ?, ?, ?, ?, ?)
  ERROR: [SQLITE_CONSTRAINT]  Abort due to constraint violation (NOT NULL constraint failed: FLAT.ID)
  </code></pre>
  
  <p>as I understand Hibernate didn't add null field (ID) into generated sql query. So maybe someone know how to fix this?
  thanks in advance.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p><a href="https://github.com/gwenn/sqlite-dialect/blob/master/src/main/java/org/hibernate/dialect/SQLiteDialect.java" rel="nofollow">dialect I copied from here</a></p>
  
  <p><strong>dll</strong></p>
  
  <pre><code>CREATE TABLE ADDRESS
  (
      ID INTEGER PRIMARY KEY NOT NULL,
      NAME TEXT NOT NULL
  );
  CREATE TABLE FLAT
  (
      ID INTEGER PRIMARY KEY NOT NULL,
      CRTN_DATE TEXT NOT NULL,
      ADDRESS_ID INTEGER NOT NULL,
      ROOM_CNT INTEGER NOT NULL,
      AREA REAL NOT NULL,
      PHONE TEXT NOT NULL,
      PRICE REAL NOT NULL,
      FOREIGN KEY (ADDRESS_ID) REFERENCES ADDRESS (ID) DEFERRABLE INITIALLY DEFERRED
  );
  </code></pre>