卡拉夫-白羊座JPA错误-需要主动协调

时间:2018-10-01 13:14:23

标签: entitymanager karaf aries

我正在将Karaf 4.2.0与Aries JPA一起使用。 当我使用EntityManager时,出现错误-

  

java.lang.IllegalStateException:需要主动协调

blueprint.xml

<blueprint...>
<jpa:enable />
<bean id="testDAOImplJPA-CM" class="com.test.TestDAOImpl">
    <tx:transaction method="*" value="Required" />
</bean>
</blueprint>

TestDAOImpl.java

public class TestDAOImpl {
@PersistenceContext(unitName = "test-cm")
private EntityManager entityManager;
@Override
public void doAction() {
   ChildA child = new ChildA (entityManager);
   child.testEm();
}
}

ChildA .java

public class ChildA {
private EntityManager em;
public ChildA(EntityManager em) {
this.em = em;
} 
public void testEm() {
CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
}
}

当我在ChildA类中使用em时,出现上述错误。

0 个答案:

没有答案