• Post Reply Bookmark Topic Watch Topic
  • New Topic

primary key

 
Popescu Ion
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
I'm using OpenJPA. Have a entity named "catalog", and every time I'm working with it, I delete then repopulate the table with fresh new data.
Question : what is the command for setting primary key back to "1" every time I'm deleting data within table ?

Example :

id name description
1 someName1 someDescription1
2 someName2 someDescription2
3 someName3 someDescription3

Then, after deleting and repopulating, i got this :


id name description
4 someName1 someDescription1
5 someName2 someDescription2
6 someName3 someDescription3

How to set this id to start every time on "1".
Thnx in advance and sorry for my bad english.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A question worth considering is why do you want to do this? What purpose does the "1" serve if it has the same meaning as the lowest id? I'm asking because resetting the key adds a degree of complexity to no real benefit (unless you have a compelling argument for it?)
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!