Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6726155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:53:36+00:00 2026-05-26T09:53:36+00:00

I am using DB2 for my application. I run some insertion script after creating

  • 0

I am using DB2 for my application. I run some insertion script after creating database. That insertion script generates records in table with id’s given in insertion script.

Suppose for abc table insertion script creates a record with id = 3. As id’s are set to auto generated in hibernate so while saving third record from application I got exception.

        Caused by: com.ibm.websphere.ce.cm.DuplicateKeyException: One or
 more values in the INSERT statement, UPDATE statement, or foreign
 key update caused by a DELETE statement are not valid
 because the primary key, unique constraint or unique
 index identified by "1" constrains table

I am using @GeneratedValue(strategy = GenerationType.AUTO)

What strategy = GenerationType I should use to overcome this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T09:53:37+00:00Added an answer on May 26, 2026 at 9:53 am

    Nothing works except this query.

    alter table TABLE_NAME alter column ID set GENERATED BY DEFAULT RESTART WITH 10000;
    

    DB2 should choose available ID itself but not doing so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class
Hi im using sqlalchemy on a db2 table with 500k rows. using plain sql
In my application I have a bool property named DisplayIndicator. In the database (DB2)
Hibernate criteria, using DB2 dialect, generates the following SQL with composite keys in the
I got a web application using the spring-security framework. I setted up a database
We've got an application using spring for making calls to DB2 stored procedures. The
When I try to pre-compile my DB2 Cobol application that contains embedded SQL statements,
I am running an application that used struts and hibernate. I am currently using
I have a clustered application that is suffering from database deadlocks. It is a
I have a Java application which queries a database table which the current user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.