Hi,
I have an entity "user" that consists of an entity "confidentiallevel". When saving a "user" with a new "confidentiallevel" it should persist everything. The mappings have the cascade="save-update" option.
sessionFactory.getCurrentSession().saveOrUpdate(userEntity);
I get an exception saying "ORA-02291:, integrity constraint (MYSCHEMA.FK_USER_CONFIDENTIALLEVEL) violated - parent key not found":
Code:
Hibernate: select USERS_ID_SEQ.nextval from dual
Hibernate: select CONFIDENTIALLEVEL_ID_SEQ.nextval from dual
Hibernate: insert into MYSCHEMA.CONFIDENTIALLEVEL (CONFLEVEL, ACTIVATED, ACTIVATIONCHANGE, ID) values (?, ?, ?, ?)
Hibernate: insert into MYSCHEMA.USERS (CONFIDENTIALLEVEL, NAME, PASSWORD, EMAIL, ACTIVATED, ACTIVATIONCHANGE, ID) values (?, ?, ?, ?, ?, ?, ?)
2007-07-02 14:23:44,723 [http-8080-1] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 2291, SQLState: 23000
2007-07-02 14:23:44,723 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-02291: Integritäts-Constraint (MYSCHEMA.FK_USER_CONFIDENTIALLEVEL) verletzt - übergeordneter Schlüssel nicht gefunden
2007-07-02 14:23:44,723 [http-8080-1] WARN org.hibernate.util.JDBCExceptionReporter - SQL Error: 2291, SQLState: 23000
2007-07-02 14:23:44,723 [http-8080-1] ERROR org.hibernate.util.JDBCExceptionReporter - ORA-02291: Integritäts-Constraint (MYSCHEMA.FK_USER_CONFIDENTIALLEVEL) verletzt - übergeordneter Schlüssel nicht gefunden
2007-07-02 14:23:44,823 [http-8080-1] ERROR org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) .....................
It seems as if the confidentiallevel entity isn't saved and so there occurs a foreign key violation.
What to do please?