title: Hibernate StaleObjectStateException while saving an Object
body: <p>I Have a two POJO Classes
   1. Profile.java
   2. Account.java
   3. Event.java</p>
  
  <p>Now in my code is here</p>
  
  <pre><code>try {
           String key = null;
            // By passing userId i'm getting Profile object
            Profile profile = xxxx(ProfileDAO.class)
                .findByAccountId(userId);
            key = profile.getAccount().getAccountSecretKey();
          } catch (Exception se) {
        }
        Event se = new Event();
        se.setId(event.getId());
        se.setType(event.getType());
        se.setUserId(userId);
        xxx(EventDAO.class).save(se);
  </code></pre>
  
  <p>At this stage, I'm getting StaleObjectStateException On Entity Account</p>
  
  <pre><code>stacktrace:org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.xxxxx.Account#309650]
      at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:2509)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3228)
      at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:3126)
      at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3456)
      at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:140)
      at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:377)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:369)
      at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:287)
      at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:339)
      at org.hibernate.event.internal.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:52)
      at org.hibernate.internal.SessionImpl.flush(SessionImpl.java:1234)
      at xxxxx.DAO.save(DAO.java:82)
      at  
  </code></pre>
  
  <p>Any idea why the Account entity is staled. 
  Thanks for Advance</p>