0

会話のフラッシュ モードに問題があります。

@Begin(..) アノテーションでフラッシュ モードを手動に設定すると、Hibernate はアタッチされたエンティティの変更をデータベースに直接入力します。

CustomerBranch はエンティティです

@Begin(join=true) public String 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

会話タイムアウト="120000" 親会話-id-パラメーター="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@"/>
4

1 に答える 1

0

@Beginメソッドが実行されたときに、すでに会話の中にいるのではないでしょうか? join=true別の値を指定した場合でも、前の会話を変更せずにその flushMode を変更しません。確認するには、試してみてくださいnested=true

于 2012-07-06T21:13:31.070 に答える