【问题标题】:FlushMode doesn't work冲洗模式不起作用
【发布时间】:2012-06-17 02:47:41
【问题描述】:

我对对话中的刷新模式有疑问:

如果我在 @Begin(..) 注释中将刷新模式设置为手动,Hibernate 仍会将附加实体上的任何更改直接填充到数据库中。

CustomerBranch 是实体

@Begin(join=true) 公共字符串 addCustBranch() 抛出异常 {

 CustomerBranch customerBranch=new CustomerBranch();
 BeanUtils.copyProperties(customerBranch,doCustomerBranch)

branchesMap.get(selectedBranch.toLowerCase()).getCustomerBranch().add(customerBranch)
 custBranchesList.add(customerBranch); 
 }
 @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());

}

在上述方法中,我在这里将列表添加到 custBranchesList 我不能使用任何持久化仍然直接更改反映数据库

组件.xml

conversation-timeout="120000" parent-conversation-id-parameter="pid"/>

<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@"/>

【问题讨论】:

  • 你能激活hibernates sql log看看它发出了什么吗?

标签: hibernate jpa type-conversion seam seam2


【解决方案1】:

当您的@Begin 方法执行时,您可能已经在对话中? join=true 只是保持之前的对话不变,即使您指定了另一个值,也不会更改它的 flushMode。要检查尝试nested=true

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-05-16
    • 2013-03-04
    • 2016-04-07
    • 2018-06-24
    • 2021-09-10
    • 2012-06-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多