Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Logan Lee
Greenhorn
Posts: 18
Java Mac Spring
  • Mark post as helpful
  • send pies
  • 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
Java Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any ideas? all help is very much appreciated
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic