java - Force hibernate to leave id empty -


so using postgres , hibernate 4.2.2 , entity this

@entity(name = "users") @check(constraints = "email ~* '^[a-za-z0-9._%-]+@[a-za-z0-9.-]+[.][a-za-z]+$'") @dynamicinsert public class users {   @id   @generatedvalue(strategy = generationtype.identity)   @column(name = "id_user",unique = true)   @index(name = "user_pk")   private integer iduser; 

hibernate still inserts id in table, instead of leaving emtpy database fill in. hibernate forces ids based on cache not checking database whether has lates id.

how can force can leave id blank , let database insert it?

first thought because using int , int default 0 when using object forces id there cache.

so goal let database fill ids instead of hibernate or @ least hibernate before filling in check database id first.

so error getting was
caused by: org.postgresql.util.psqlexception: error: duplicate key value violates unique constraint "users_pkey" detail: key (id_user)=(1) exists.
, wasn't caused hibernate , caching import of data @ creation of database, inserted given ids eg:
insert users(id_user,email,password,tag) values (1,'a@b.c','***','adpleydu');
, sequence generating wasn't updated if inserted pure sql via console got same error.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -