Hibernate FlushMode没有';行不通
我对对话中的刷新模式有问题: 如果我在@Begin(..)注释中将flush模式设置为manual,Hibernate仍然会将附加实体上的任何更改直接填充到数据库中 CustomerBranch是一个实体 @开始(join=true) 公共字符串addCustBranch()引发异常{Hibernate FlushMode没有';行不通,hibernate,jpa,type-conversion,seam,seam2,Hibernate,Jpa,Type Conversion,Seam,Seam2,我对对话中的刷新模式有问题: 如果我在@Begin(..)注释中将flush模式设置为manual,Hibernate仍然会将附加实体上的任何更改直接填充到数据库中 CustomerBranch是一个实体 @开始(join=true) 公共字符串addCustBranch()引发异常{ CustomerBranch customerBranch=new CustomerBranch(); BeanUtils.copyProperties(customerBranch,doCustomerBr
CustomerBranch customerBranch=new CustomerBranch();
BeanUtils.copyProperties(customerBranch,doCustomerBranch)
branchesMap.get(selectedBranch.toLowerCase()).getCustomerBranch().add(customerBranch)
custBranchesList.add(customerBranch);
}
在上面的方法中,我将列表添加到custBranchesList中,在这里我不能使用任何persist,仍然可以直接更改以反映数据库
componet.xml
会话超时=“120000”父会话-id参数=“pid”/>
当执行@Begin
方法时,可能您已经在会话中了?join=true
只是保持前一个会话未被触及,即使您指定了另一个值也不会更改其刷新模式。要检查trynested=true是否可以激活hibernates sql日志以查看它发出了什么?
@Begin(flushMode=FlushModeType.MANUAL,join = true)
public void populateSelectedList() throws Exception {
// PersistenceProvider.instance().setFlushModeManual(getEntityManager());
((Session)getEntityManager().getDelegate()).setFlushMode(FlushMode.MANUAL);
custBranchesList.clear();
custBranchesList.addAll(branchesMap.get(selectedBranch.toLowerCase()).getCustomerBranch());
}
<web:hot-deploy-filter url-pattern="/*.mobee"/>
<persistence:entity-manager-factory installed="@seamBootstrapsPu@"
name="entityManagerFactory" persistence-unit-name="mobeeadmin"/>
<persistence:managed-persistence-context auto-create="true"
entity-manager-factory="@seamEmfRef@" name="entityManager" persistence-unit-jndi- name="@puJndiName@"/>