aspose file tools*
The moose likes Object Relational Mapping and the fly likes CascadeType.ALL is not doing what I expected (int constraint violated) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "CascadeType.ALL is not doing what I expected (int constraint violated)" Watch "CascadeType.ALL is not doing what I expected (int constraint violated)" New topic
Author

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

Logan Lee
Greenhorn

Joined: Oct 28, 2009
Posts: 18

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

Joined: Oct 28, 2009
Posts: 18

any ideas? all help is very much appreciated
 
jQuery in Action, 2nd edition
 
subject: CascadeType.ALL is not doing what I expected (int constraint violated)