Eclipselink NPE上找到

时间:2016-06-06 20:09:23

标签: java jpa eclipselink

发出简单的"发现"对一个实体的操作,Eclipselink抛出一个NPE:

java.lang.NullPointerException: null
    at org.eclipse.persistence.internal.jpa.CMP3Policy.createPrimaryKeyFromId(CMP3Policy.java:224)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.findInternal(EntityManagerImpl.java:808)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:730)
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.find(EntityManagerImpl.java:599)

该实体使用多租户和每个租户的策略。

1 个答案:

答案 0 :(得分:1)

确保您在实体管理器上设置租户属性,如下所示:

String tenant = // ...
EntityManager em = // ...
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, tenant);