我正在使用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之间按顺序排列。
为什么会这样!任何想法...... ??
答案 0 :(得分:0)
parameter5的类应该是实体。
也许您的parameter5是FK,如果是,则需要使用parameter5.parameter查找实变量。