• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Hibernate: Creating Entities versus the database schema, best way create the Sequence

 
Ranch Hand
Posts: 71
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try to make myself 'comfortable' with the Java eco-system as JPA and Hibernate.

I have for instance made a class employee with sequence:


I can CRUD records with Postman is working perfectly.

But now I have inserted records with SQL (INSERT INTO table name ()).
Now I try to insert a record with postman, I get the error message: rg.h2.jdbc.JdbcSQLIntegrityConstraintViolationException: Unique index or primary key violation: "PRIMARY KEY ON PUBLIC.ADDRESS(ID) [1, 'town name', '0', 'street name']"; SQL statement:

I think that's due that I add records by SQL statements. Hibernate 'thinks'  the sequence is still one and I can imagine that it goes wrong.

In the 'real (=production)' environment, what is than the best way to implement this?
Defining the complete schema with Liquibase/flyaway for example and simply define sequence as:

And are there some more 'little' things where I need to have tobe where off?
 
reply
    Bookmark Topic Watch Topic
  • New Topic