• 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

CascadeType.ALL is not doing what I expected (int constraint violated)

 
Greenhorn
Posts: 18
Mac Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using JBoss5.1.0GA (hibernate) and Oracle XE.
A book can have one or multiple authors (as reflected below)
When I persist a book, it contains a collection of authors. I want the authors also to be persisted (cascade)

I have three tables.

BOOK_TBL
BOOK_ID (PK)
BOOK_AUTHOR_TBL
BOOK_ID (FK)
AUTHOR_ID (FK)
AUTHOR_TBL
AUTHOR_ID (PK)

I have two Entities:
Code snippets:
Book


Author
Nothing special here, except I use a sequence for the PK


When I persist my book, I get:


So it seems it's trying to insert the FK's in the mapping table but can't find the parent key yet.. What am I doing wrong?
 
Logan Lee
Greenhorn
Posts: 18
Mac Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
any ideas? all help is very much appreciated
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic