Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • D DataEngineering
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 10
    • Issues 10
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar

Diese GitLab Instanz ist nicht für den produktiven Einsatz gedacht!
Bitte https://gitlab.ost.ch benutzen!
Diese Instanz ist nur nuch zur Datenmigration online.

Vielen Dank für euer Verständnis.

  • Lehre und Unterricht
  • Datenbank- und Informations-Systeme
  • DataEngineering
  • Issues
  • #2

Closed
Open
Created Feb 22, 2017 by Marcel Huber@m1huberOwner

Dynamically set next valid sequence value

Context

OR-Mapper_JPA: Aufgabe 5

Summary

Inserting a new entry into one of the tables fails as the import does not correctly update the sequence counters.

Steps to reproduce

  • Run the Program and expect the insert to fail on an existing Id

What is the current bug behavior?

Inserting an entity having @GeneratedValue(strategy = GenerationType.IDENTITY) set will fail if the generated IDENTITY value is already existing.

What is the expected correct behavior?

The generated IDENTITY should be greater than the last inserted id.

Possible fixes

According to http://stackoverflow.com/questions/244243/how-to-reset-postgres-primary-key-sequence-when-it-falls-out-of-sync#answer-3698777 we can use the following statement to dynamically update the sequence:

SELECT setval(pg_get_serial_sequence('table', 'column'), coalesce(max(column),0) + 1, false) FROM table;
Assignee
Assign to
Time tracking