• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Set an auto-incremented key

 
Juri Glass
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I want to set a auto-incremented key by myself. How to achieve this?

The class looks at the moment like this:


The corresponding field in the database has the auto-increment flag attached.

I am using JPA/Hibernate/MySQL/Tomcat. Btw.: I cannot change the database schema.

Edit:
If I set the id in an instance and commit it, I get this exception:



 
Juri Glass
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I removed the

and its working.

But now I have to submit for every instance an id. Nice would be something like:
If no id given, generate one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic