Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Hibernate deleting from and reordering a DB

 
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
 
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
 
What's that smell? I think this tiny ad may have stepped in something.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic