I've tried to use Hibernate with BEA Weblogic server 8.1.3.
I have an object (Customer), which has one-to-many related children (Addresses). Children have many-to-one relation to their parent.
First I create a parent and attach to it a child - I put it into List (I also specified the parent from the child) and call save(parent).
Then I start pre pairing a second child, which depends on the created id of the parent. I call a HQL query, to make some checks, and because of this query a flush occurs.
In this flush, the parent object is first inserted, then the child. The correct values seem to be bound to parent and child insert statements according to the log.
The problem is, when child is being inserted, I get ConstraintViolationException on the foreign key of the child table, which points to the parent.
It seems as if the parent has not been inserted, even though Hibernate's SQL log shows that it has been. Then I disabled the constraints, but the flush still failed - this time when updateing the parent record later in the flush procedure.
I even ran my program outside the WebLogic container (using a straight JDBC connection and not JTA, of course). It actually worked with Hibernate 2.1 and running outside WebLogic (failed when ran in it), but it failed with Hibernate 3.0.5 inside or outside WebLogic.
Looks like a beginner's mistake, but I just can't find a solution on the forums.
Excerpt from the log:
DEBUG[26.10.2005 17:25:47],main
Inserting entity: [si.marand.adslService.database.data.project.CustomerData#15235793]
DEBUG[26.10.2005 17:25:47],main
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG[26.10.2005 17:25:47],main
insert into Customer (code, name, agent_id, remark, tax_id, organization, organization_name, organization_number, contact_person, giro_account, liable_to_taxation, last_name, first_name, gender, birth_date, vat_status_id, customer_category_id, information_center_id, person_number, foreigner, customer_type_id, prefix, sp, payment_term_id, id_ddv, creator_id, create_timestamp, customer_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG[26.10.2005 17:25:47],main
preparing statement
DEBUG[26.10.2005 17:25:47],main
Dehydrating entity: [si.marand.adslService.database.data.project.CustomerData#15235793]
DEBUG[26.10.2005 17:25:47],main
binding '15235793' to parameter: 1
...
DEBUG[26.10.2005 17:25:47],main
binding '15235793' to parameter: 28
DEBUG[26.10.2005 17:25:47],main
Inserting entity: [si.marand.adslService.database.data.project.AddressData#441636]
DEBUG[26.10.2005 17:25:47],main
about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG[26.10.2005 17:25:47],main
closing statement
DEBUG[26.10.2005 17:25:47],main
about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
DEBUG[26.10.2005 17:25:47],main
insert into Address (address_type_id, street1, street2, city, country_id, addressee_id, post_office_id, creator_id, create_timestamp, address_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
DEBUG[26.10.2005 17:25:47],main
preparing statement
DEBUG[26.10.2005 17:25:47],main
Dehydrating entity: [si.marand.adslService.database.data.project.AddressData#441636]
DEBUG[26.10.2005 17:25:47],main
binding '1' to parameter: 1
DEBUG[26.10.2005 17:25:47],main
binding 'linhartova 92' to parameter: 2
...
DEBUG[26.10.2005 17:25:47],main
binding '441636' to parameter: 10
DEBUG[26.10.2005 17:25:47],main
about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
DEBUG[26.10.2005 17:25:47],main
closing statement
DEBUG[26.10.2005 17:25:47],main
could not insert: [si.marand.adslService.database.data.project.AddressData] [insert into Address (address_type_id, street1, street2, city, country_id, addressee_id, post_office_id, creator_id, create_timestamp, address_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]
java.sql.SQLException: ORA-02291: integrity constraint (IMF.SYS_C0019525) violated - parent key not found
|