[jboss-user] [EJB 3.0] - EntityManager is loosing updates

konstantin.ermakov do-not-reply at jboss.com
Mon Dec 4 09:55:09 EST 2006


Hello!

   I have the following problem. In our project we are using the standart design - there is one EntityBean pojo per table, and one Stateless session bean which is working with the table. We are also using rich clients, which are manipulating the data, i.e.:


  | 
  | @Entity
  | public class SomeObject {
  | 
  | private Integer id_;
  | 
  | private String name_;
  | 
  | @Id
  | public void setId( Integer id ) {
  |  id_ = id;
  | }
  | 
  | public Integer getId() {
  | return id_;
  | }
  | .....
  | 
  | };
  | 
  | 
  | @Stateless
  | public class SomeStatelessBean {
  | 
  |  @PersistenceContext(name = "myname", unitName = "myunit")
  |   private EntityManager manager;
  |    
  | 
  |    public SomeObject getObject() {
  |      return manager.find(SomeObject.class, id);
  |    };
  | 
  |    public update( SomeObject detached ) {
  |      SomeObject obj = manager.find(detached.id);
  |      obj.setName( detached.getName );
  |      manager.flush();
  |    };
  | 
  | };
  | 

In the background there is a Timer Bean which is reading SomeObject information ( it does not manipulate, just reading ). 

The problem is as following. If I am calling update() very often my EntityManger returns me the old with the getObject() method object, though I am sure that the new copy is in database (Oracle). Can somebody tell me why does it happen?

There are no exceptions on the server side, just the data is wrong.

Thank you,
Sincerely yours, Konstantin

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3991018#3991018

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3991018



More information about the jboss-user mailing list