These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: XA Transaction commit order?
PostPosted: Mon Sep 25, 2006 12:52 pm 
Newbie

Joined: Mon Sep 25, 2006 12:37 pm
Posts: 1
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.