jpa - Object not fetch well in java -


i have problem fetching objects in java. there object entity bean class , contains object b (other entity bean class) field. object created without b , later object b attached action.
problem users can not see object b in object a, looks null. in database fine , after time object looks (contains b). happens in cases, in other object looks begin.
want use 2 virtual machines running application (maybe can problem) , oracle application server.
help?
stojan

code looks like:
entity class defined (b entity class).

 @entity  @table(name = "a")  public class a{      ...      @manytoone      @joincolumn(name="id_b", referencedcolumnname="id")      private b b;      ...  } 

object of class created in action, example:

public createa_action(){      a = new a();      saveobject(a); } 

where 'saveobject' method persist or merge object in database.

later, there call of other method, this:

public addbtoa_action(){      a = geta();      b b = getb();      a.setb(b);      saveobject(a); } 

where geta() , getb() existing objects.

well, each entitymanager (session in hibernate) has own in-memory instances of entity. have 1 entitymanager per transaction , 1 transaction per http-request.

so if 1 entity instance loaded in given transaction t1 , loaded in transaction t2, if set 'a' field on entity in t1, won't able see modification in t2 until t1 commited * , entitymanager.refresh() method called on given entity.

* transaction isolation level in jpa read_commited


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -