您试图设置类型实体的值

时间:2012-04-18 18:33:44

标签: jpa eclipselink

我正在使用jpa 2和eclipslink ...

我正在尝试执行此查询:

列出postEntityList = entityManager.createQuery(“从PostEntity p中选择p,其中p.organizationEntity =?1和p.organizationUnitEntity =?2和p.organizationLocationEntity =?3和p.organizationBatchEntity =?4和p.postCategoryEntity =? 5和p.dateOfPosting在?6和?7之间通过p.rating desc“)。setParameter(1,organizationEntity).setParameter(2,organizationUnitEntity).setParameter(3,organizationLocationEntity).setParameter(4,organizationBatchEntity).setParameter( 5,postCategoryEntity)。setParameter(6,minimumTime).setParameter(7,maximumTime).getResultList();

但我收到错误:

您试图为参数5设置类型class entity.PostCategoryEntity的值,具有类实体的预期类型。来自查询字符串的组织实体从PostEntity p中选择p,其中p.organizationEntity =?1和p.organizationUnitEntity =?2和p.organizationLocationEntity =?3和p.organizationBatchEntity =?4和p.postCategoryEntity =?5和p.dateOfPosting在?6和?7之间按顺序排列。

为什么会这样!任何想法...... ??

1 个答案:

答案 0 :(得分:0)

parameter5的类应该是实体。

也许您的parameter5是FK,如果是,则需要使用parameter5.parameter查找实变量。