Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate deleting from and reordering a DB

 
josef corkery
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so im having a world of trouble at the moment with my DB and hibernate (also this may be very obvious but im new to hibernate).
i am working with the current table structure below, which i know isnt great but that what ive been given.
Im trying to delete elements from my database and have them cascade down and thats working.
The problem is my keys are numbered sequecially and i use these key values to show on my screen. Now my problem is when i delete something in table 2.
For example i have 5 items in that table and i delete 2 and 4 i am not sure how to reorder that table so now i have elements 1 2 and 3.
Ive tried to just set my elements to different numbers say change element 3s table2key to 2 but no go.
Ive also tried to strip all the elements out and put them back in one at a time but then it tries to put the 3rd tables elements into the DB before the second and of course it fails as table 2 has no corresponding entries.
sorry if this is a bad explaination
but can anyone help, or at least try to figure out what im saying.
I will be watching the boards if any more clarification is sought.
thanks
josef


table 1
table1Key
element 1
element 2
element 3
element 4

table 2
table1Key
table2Key
element 1
element 2

table 3
table1Key
table2Key
table3Key
element 1
 
Ravindra Rawat
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is my keys are numbered sequecially and i use these key values to show on my screen.


If this is not a absolute necessity, then use a simple incremental integer value while displaying on the screen instead of something internal to your database.

Cheers
Ravindra S. Rawat
"Sometimes you win, sometimes you learn". -Unknown
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic