File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Problem when querying after create or update Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "Problem when querying after create or update" Watch "Problem when querying after create or update" New topic
Author

Problem when querying after create or update

Naveen Sampra
Ranch Hand

Joined: Jun 11, 2003
Posts: 70
I have service method call createProduct():

Another service method call listProducts():

The above 2 service calls are made in the same transaction context. i.e. first create the product and get a listing of products.

The problem is, productList listing contains "product1" instance in memory(created from createProduct()) instead of reading corresponding row from DB.
The same happens when a product is edited and then the DB is queried. The query contains the edited object in memory.

How can this happen ? Has anyone encountered this situation. How do I solve this problem.

Note:- I'm using Spring's declarative transaction management. I'm also using OpenSessionViewFilter. Therefore FLUSH_MODE = NEVER.

Any help is appreciated.
Jaikiran Pai
Saloon Keeper

Joined: Jul 20, 2005
Posts: 6718

If you are updating and retrieving the object as part of the same session then Hibernate is going to get the object directly from its session (first level cache).


[My Blog] [JavaRanch Journal]
 
 
subject: Problem when querying after create or update
 
Threads others viewed
is it advisable to use super.execute()?
Factory Vs Abstract Factory Pattern
what if the 'starting' page needs some "action" ?
IBM Test: Coupling question
No collection found
WebSphere development made easy
without the weight of IBM tools
http://www.myeclipseide.com