-->
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.  [ 3 posts ] 
Author Message
 Post subject: False negative read
PostPosted: Thu Jun 07, 2012 10:08 am 
Newbie

Joined: Thu Jun 07, 2012 10:03 am
Posts: 8
I have a web application that consists of a web service with two operations: `createA` and `createB`. An handler is registered for the endpoint. This handler opens a Session and start a transaction when the request is received. Then the code of the requested operation is executed. Before the response is sent back, the transaction is committed and the session is closed.

The code of `createA` consists of creating an entity of type `A` and persisting it using `Session.save()` method. In DEBUG mode, after `Session.save()` is called, I can see that there is one insertion in the ActionQueue of the session.

The code of `createB` consists of :

- retrieving the previously created entity of type `A`
- creating an Entity `B` that references the instance of `A` (B has a property that represents an associated `A`)
- updating `A` to reference the new instance of `B`
- call `Session.save()` for the new instance of `B`
- call `Session.update()` for the new modified instance of `A`

However, in DEBUG mode, after calling `Session.save()` and `Session.update()`, the ActionQueue of the corresponding Session is empty. But, after the transaction commits, I can see the created entity in the database.

Operation `createA` and `createB` are invoked in this order without DEBUG. An error appears during the execution of the create `B` when it tries to retrieve the instance of `A` previously created using a criteria and the `Session.list()` method. The problem is that the instance of `A` is not found.

However, if I repeat the same sequence of operations in DEBUG or using `Thread.sleep(15s)` between invocations of the two operations, the instance of `A` can be found.

I also precise that it works on certain machines but not on others. And I don't see any differences between these machines.

Thanks


Top
 Profile  
 
 Post subject: Re: False negative read
PostPosted: Sun Jun 10, 2012 9:33 am 
Newbie

Joined: Thu Jun 07, 2012 10:03 am
Posts: 8
Any idea?


Top
 Profile  
 
 Post subject: Re: False negative read
PostPosted: Mon Jun 11, 2012 12:55 pm 
Beginner
Beginner

Joined: Mon Jun 04, 2012 12:31 pm
Posts: 20
Have you tried persisting B before you start making the associations?


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

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.