Cannot insert explicit value for identity column


2008-01-28 Digg! icurtain Delcious icurtain Technorati icurtain


ERROR [org.hibernate.util.JDBCExceptionReporter] Cannot insert explicit value for identity column in table 'table' when IDENTITY_INSERT is set to OFF.

ERROR [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session

org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update

Solution

Annotate the function in the bean with the following:

@GeneratedValue(strategy=GenerationType.AUTO)