Application server: JBoss 4.0.4-GA
Hibernate version: 3.2.0cr2
Name and version of the database you are using: Oracle 10g
hi all,
bit of a thorny (or silly) question. the setup:
Ok, for some reason (don't ask), we have multiple datasources that talk to the same database (different schemas). There are referential integrity constraints between the schemas. Let's pretend we have an Orders schema (with an Order table), and a Customers schema (with a Customer table). There is a reference from Order to Customer.
Now, let's say I want to create a new Order, for a new Customer. I have an OrderSessionBean.createOrder() method that creates an Order entity - this method calls a CustomerSessionBean.createCustomer() method that creates a Customer entity. When the container tries to commit this at the conclusion of the createOrder() method, Oracle fails saying that it cannot find the Customer that the Order is pointing to.
Basically, the problem is that the transaction manager is trying to commit the Order creation before the Customer creation...so Hibernate flushes the Order insert, and gets the SQL error. If i manually flush the Customer insert first, then all is well (or seems to be).
So...the question is: is there a way to achieve this 'automatically' without manually flushing the Customer session? Is JBoss (or Hibernate) smart enough to realise that my two independent Hibernate configurations/JCA Datasources are actually pointing to the same database and that there are referential integrity constraints that need to be checked? I strongly suspect not (to the point that i feel a bit silly even asking), but I have to ask.
|