java - ManyToOne Unidirectional Disable Constraint -


i have following unidirectional manytoone relation:

@entity @table(name = "child") public class child {     @id     private integer id;      @manytoone(cascade = cascadetype.all, fetch = fetchtype.eager)     private parent parent;  }  @entity @table(name = "parent") public class parent{     @id     private integer id; } 

when trying delete parent entity database have constraint violation.

ora-02292: integrity constraint violated - child record found

what need parent entity deleted if has children, children entity should stay.

how change relation?

you can't jpa if using relationship. making manytoone indicates value in foreign key field exist in parent table. jpa not able distinguish between null fk value , there being fk value doesn't have associated row in parent table.

if must done (and shouldn't imo), need map integer foreign key value in child basic mapping instead of manytoone. allows set independently of there being existing parent entity - null means null, value means value. can query associated parent entity if entity needed.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -