Java hibernate spring执行顺序存储过程

Java hibernate spring执行顺序存储过程,java,spring,hibernate,java-stored-procedures,Java,Spring,Hibernate,Java Stored Procedures,我正在使用hibernate和spring(用于事务管理),并且有这样一个DAO @Transactional class Dao{ public save(Entity e){ //stored an entity Entity saved = entityManager.merge(e); //flush the dataset to the db entityManager.flush(); //updates the saved entity with a stored proce

我正在使用hibernate和spring(用于事务管理),并且有这样一个DAO

@Transactional
class Dao{

public save(Entity e){
//stored an entity
Entity saved = entityManager.merge(e);

//flush the dataset to the db
entityManager.flush();

//updates the saved entity with a stored procedure
entityManger.createNameQuery(STORED_PROCEDURE).setParameter(0, saved.getId()).executeUpdate();
}
}
将在以下环境中执行,结果不同:

  • 朱妮特:这里一切都很好。实体将被存储,存储过程将更新保存的数据集
  • Glassfish上的EJB:首先执行存储过程,然后执行保存操作(我记录来自hibernate的sql命令)。似乎没有执行冲水
因此,存储实体不包括存储过程的更新。我不知道为什么这些操作在Glassfish环境中以不同的顺序执行,并且在Junit测试用例中一切都很好


有什么想法吗?

在这两种情况下,实体经理是如何创建的?可能是在一种情况下,您有一个带有一些设置的持久性单元,而在其他情况下,不同的设置实体管理器将通过spring进行配置。两种环境都有不同的设置:JUnit:资源定义为resource_LOCAL,使用JpaTransactionManager Glassfish:资源定义为JTA,使用JtaTransactionManager。您知道原因了。您的平台事务管理器可能不同。