"NULL not allowed for column 'id'" even though log says it had value bound "NULL not allowed for column 'id'" even though log says it had value bound postgresql postgresql

"NULL not allowed for column 'id'" even though log says it had value bound


it occured to me another possible solution for creating a correct CREATE TABLE statement.

http://mrbool.com/how-to-create-database-table-using-hibernate/28269

The great thing is that:

<property name="hbmdl.auto">update</property>

With this solution, your code will generate a statement itself. Try it!


The problem turned out to be an @Entity with a @UniqueConstraint that someone had missed completing before committing the code.

As it turns out this gave us a plethora of different behaviors and errors when generating tables for H2 & postgres through both Hibernate and EclipseLink during test phase!

We finally caught the problem by remote-debugging the the maven surefire plugin through Eclipse.

@Entity@Table(name = "dyn_bin_constraint_group", schema = "public",         uniqueConstraints = { @UniqueConstraint(columnNames = {}) })public class BinConstraintGroup implements Serializable {

The solution was simply completing the @UniqueConstraint!

@Entity@Table(name = "dyn_bin_constraint_group", schema = "public",         uniqueConstraints = { @UniqueConstraint(columnNames = {BinConstraintGroup.NAME}) })public class BinConstraintGroup implements Serializable {


Your ID column is "systemuseridnr".

  1. You'd like to fill it out automatically as you annotated in your entity with using sequence "systemuser_pk_seq" - Have you got this sequence in the DB?
  2. All the same, you'd like to fill it out directly with value "-1" - In an ID column you must not use negative.