Hi i am new to hibernate technology and i have few issues.
Suppose if there are two tables. For Example:
Table1 table1_ID table1_value Table2 table2_ID table2_name
If table1_ID is primary key of table1 and (table2_ID and table2_name ) - primary key of table2.
table2_ID of Table2 is referencing table1_ID of Table1 (in hibernate one - to - many mapping)
I have sequence generator for table1_ID. If I try to insert I will give values only for table1_value and table2_name. So now will the sequence created for table1_ID will be assigned to table2_ID ? Because I am getting error stating "null cannot be inserted in table2.ID". How to solve this issue?
Then for dele开发者_StackOverflow社区ting... If I delete gethibernatetype().delete(objectofTable1)
.... Its again throwing me error
SQL Error: 2292, SQLState: 23000 [ERROR] 2010-02-18 19:58:37 (JDBCExceptionReporter.java:logExceptions:78) ORA-02292: integrity constraint violated - child record found [ERROR] 2010-02-18 19:58:37 (AbstractFlushingEventListener.java:performExecutions:301) Could not synchronize database state with session org.hibernate.exception.ConstraintViolationException: could not delete:
I have set ondelete=cascade
too. How to solve this?
In your mappings you have a collection. You have to set it to be cascade=all
(or if using annotations - cascade=CascadeType.ALL
精彩评论