title: hibernate doesn't issue update after flush
body: <p>I'm using hibernate 3.2.7 (same problem on 3.2.5) with spring 3.0.1, all deployed on weblogic 10.3 and with an Oracle 10g database. I'm using JTA transaction management and the transaction is distributed (it is actually started and ended in another application, this code is just in between).</p>
  
  <p>The configuration used by hibernate is declared in my persistence.xml and is the following:</p>
  
  <pre><code>&lt;property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/&gt;
  &lt;property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.WeblogicTransactionManagerLookup"/&gt;
  &lt;property name="hibernate.query.factory_class" value="org.hibernate.hql.classic.ClassicQueryTranslatorFactory"/&gt;
  &lt;property name="hibernate.current_session_context_class" value="jta"/&gt;
  &lt;property name="hibernate.connection.release_mode" value="auto"/&gt;
  </code></pre>
  
  <p>The spring configuration regarding the transaction manager is the following:</p>
  
  <pre><code>&lt;!-- Instructs Spring to perfrom declarative transaction managemenet on annotated classes --&gt;
  &lt;tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/&gt;
  
  &lt;!-- Data about transact manager and session factory --&gt;
  &lt;bean id="txManager" class="org.springframework.transaction.jta.WebLogicJtaTransactionManager"&gt;
    &lt;property name="transactionManagerName" value="javax.transaction.TransactionManager"/&gt; 
    &lt;property name="defaultTimeout" value="${app.transaction.timeOut}"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
    &lt;!-- persistence unit is missing jta data source so that application server is not 
        creating EntitiyManagerFactory, spring will create its own LocalContainerEntityManagerFactoryBean overriding data source--&gt;
    &lt;property name="dataSource" ref="myDataSource"/&gt;
    &lt;!-- specific properties like jpa provider and jpa provider properties are in persistance unit --&gt;
    &lt;property name="persistenceUnitName" value="my.persistence.unit"/&gt;
  &lt;/bean&gt;
  
  
  &lt;!-- define data source in application server --&gt;
  &lt;jee:jndi-lookup id="myDataSource" jndi-name="${db.jndiName}"/&gt;
  </code></pre>
  
  <p>I'm using a generic CrudDao with an update method that looks like this:</p>
  
  <pre><code>public void update(Object entity) {
      //entityManager injected by @PersistenceContext
      entityManager.merge(entity);
      entityManager.flush();
  }
  
  public Object getById(Object id, Class entityClass) throws PersistenceException{
      return (Object)entityManager.find(entityClass, id);
  }
  </code></pre>
  
  <p>UPDATED: added the getById method.</p>
  
  <p>The code that does not work as expected looks like this:</p>
  
  <pre><code>MyObject myObj = getMyObjectThroughSomeOneToManyRelation(idOne, idOther);
  // till now was null
  myObj.setSomeDateAttr(someDate);
  genericDao.update(myObj); 
  
  MyObject myObjFromDB = genericDao.getById(myObj.getId(), MyObject.class);
  </code></pre>
  
  <p>The result is that if I print myObj.getSomeDateAttr() it returns me the value of someDate, if I print myObjFromDB.getSomeDateAttr() it still has null.</p>
  
  <p>I've tried changing the update method to:</p>
  
  <pre><code>org.hibernate.Session s = (org.hibernate.Session) entityManager.getDelegate();
  s.evict(entity);
  s.update(entity);
  s.flush();
  </code></pre>
  
  <p>And it still doesn't work. </p>
  
  <p>When turning on the show_sql flag of hibernate I don't see any update occurring when doing flush nor when I query the entity manager for the object with the same id. The selects are all visible.
  UPDATE:
  At the end of the transaction the update is actually called and everything is written to the db. So my problem is "just" during the transaction.</p>
  
  <p>I'm afraid the problem may be linked with the configuration of the transaction manager on spring and on hibernate.</p>
  
  <p>Hope that someone can help me as I have already lost a day and a half with no luck.</p>