• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can deletion trigger unique constraint violation? Hibernate 2

 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
the following sql ran on the db (oracle):
alter table abc add constraint c_abc unique(abc1,abc2,abc3).
On deletion I get :
net.sf.hibernate.exception.ConstraintViolationException: could not update "abc hibernate class name"...
.......
Caused by: java.sql.SQLException: ORA-00001: unique constraint (DBNAME.c_abc) violated
......
How can this happen in deletion?

Thank you,
John.

PS
On insertion it allows me to crate a two records with the same value in abc2 but different case. But it does not allow to delete it.
 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Turn on SQL-output and have a look if you are really performing a DELETE. Do you have a db trigger which intercepts the DELETE and replaces it with an UPDATE?
 
John Landon
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thank you for your answer. I am not looking for trivial answers though.
I am permitted to delete and obviously I do not have any triggers.
Any other ideas?

Thanks.
 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why is it obvious that you do not have any triggers? Can you show us the generated sql-queries? What are you doing when the error shows up? Do you want to replace an existing row by another one by delete the old and insert the new one? If you do so, try if it works if you call flush() (if that existed in Hibernate2) between delete and insert.
 
Ranch Hand
Posts: 51
Hibernate Eclipse IDE Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Christian is right you need to see the SQL.
You should not get a ORA-00001 error on a delete so it is doing something your not expecting, and the SQL will show your that.
Could you be deleting a record than inserting a recond with the key you just deleted? If the delete is failing you could get the error.


PS in Oracle ABC2 does not equal abc2 it is case sentitive. But are you messing up on the case when tring to delete it? This could also be part of the problem above.
 
Do Re Mi Fa So La Tiny Ad
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic