Spring数据jpa存储库查询关键字“;在;不适用于openJPA 2.3.0或更高版本

Spring数据jpa存储库查询关键字“;在;不适用于openJPA 2.3.0或更高版本,jpa,spring-data,spring-data-jpa,openjpa,spring-orm,Jpa,Spring Data,Spring Data Jpa,Openjpa,Spring Orm,修改: 我已经修改了标题以获得更详细的信息 经过验证,问题是当我们使用openJPA lib版本2.3.0或更高版本时,存储库查询关键字“In”不起作用 工作正常的原始lib依赖项如下所示 openjpa: 2.2.2 Spring framework(orm, test, context, etc..): 4.1.1.RELEASE spring-data-jpa: 1.3.0.RELEASE postgres-jdbc: 9.4-1201-jdbc41 jdk: 1.7 如果openjpa

修改:

我已经修改了标题以获得更详细的信息

经过验证,问题是当我们使用openJPA lib版本2.3.0或更高版本时,存储库查询关键字“In”不起作用

工作正常的原始lib依赖项如下所示

openjpa: 2.2.2
Spring framework(orm, test, context, etc..): 4.1.1.RELEASE
spring-data-jpa: 1.3.0.RELEASE
postgres-jdbc: 9.4-1201-jdbc41
jdk: 1.7
如果openjpa已升级到2.3.0、2.4.0或2.4.1,则查询关键字“In”将始终保留在第一次给出的参数中

即使我们已经将所有可能相关的libs升级到最新版本,但仍然无法工作。JDK1.7或1.8(使用相应的postgreSQL jdbc驱动程序)


更新:

看起来中的存储库查询关键字
在这里有问题

我们试图测试findByDeviceId,代码如下,只使用findBy而不是findByIn

        List<Subtask> subtasks = this.subtaskDao.findByDeviceId("1000000002");
        print(subtasks);
        List<Subtask> subtasks1 = this.subtaskDao.findByDeviceId("1000000003");
        print(subtasks1);
        List<Subtask> subtasks2 = this.subtaskDao.findByDeviceId("1000000004");
        print(subtasks2);enter code here
和junit测试如下

@NoRepositoryBean
public interface DaoBase<T extends EntityBase, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T>
{}
List<Subtask> subtasks = this.subtaskDao.findByDeviceIdInAndStateInOrderByIdAsc(Arrays.asList(new String[]{"1000000002"}), Arrays.asList(new Integer[]{5,10}));
System.out.println("1" + subtasks);
print(subtasks);
List<Subtask> subtasks1 = this.subtaskDao.findByDeviceIdInAndStateInOrderByIdAsc(Arrays.asList(new String[]{"1000000003"}), Arrays.asList(new Integer[]{5,10}));
System.out.println("2" + subtasks1);
print(subtasks1);
List<Subtask> subtasks2 = this.subtaskDao.findByDeviceIdInAndStateInOrderByIdAsc(Arrays.asList(new String[]{"1000000004"}), Arrays.asList(new Integer[]{5,10}));
System.out.println("3" + subtasks2);
print(subtasks2);

private void print(List<Subtask> subtasks)
{
    for (Subtask subtask : subtasks)
    {
        System.out.println(subtask.getId() + ", " + subtask.getDeviceId());
    }
}
1[devicemanage.repository.appdeploy.entity.Subtask@77a9ac36, devicemanage.repository.appdeploy.entity.Subtask@3c743d40]
444, 1000000002
2[devicemanage.repository.appdeploy.entity.Subtask@3a5ce4b8, devicemanage.repository.appdeploy.entity.Subtask@38848217]
444, 1000000002
3[devicemanage.repository.appdeploy.entity.Subtask@511d5e6e, devicemanage.repository.appdeploy.entity.Subtask@7a78d380]
444, 1000000002
但是当我们将openJPA库升级到2.3.0或更高版本(2.4.0或2.4.1)时。结果将变得不正确,如下所示

@NoRepositoryBean
public interface DaoBase<T extends EntityBase, ID extends Serializable> extends JpaRepository<T, ID>, JpaSpecificationExecutor<T>
{}
List<Subtask> subtasks = this.subtaskDao.findByDeviceIdInAndStateInOrderByIdAsc(Arrays.asList(new String[]{"1000000002"}), Arrays.asList(new Integer[]{5,10}));
System.out.println("1" + subtasks);
print(subtasks);
List<Subtask> subtasks1 = this.subtaskDao.findByDeviceIdInAndStateInOrderByIdAsc(Arrays.asList(new String[]{"1000000003"}), Arrays.asList(new Integer[]{5,10}));
System.out.println("2" + subtasks1);
print(subtasks1);
List<Subtask> subtasks2 = this.subtaskDao.findByDeviceIdInAndStateInOrderByIdAsc(Arrays.asList(new String[]{"1000000004"}), Arrays.asList(new Integer[]{5,10}));
System.out.println("3" + subtasks2);
print(subtasks2);

private void print(List<Subtask> subtasks)
{
    for (Subtask subtask : subtasks)
    {
        System.out.println(subtask.getId() + ", " + subtask.getDeviceId());
    }
}
1[devicemanage.repository.appdeploy.entity.Subtask@77a9ac36, devicemanage.repository.appdeploy.entity.Subtask@3c743d40]
444, 1000000002
2[devicemanage.repository.appdeploy.entity.Subtask@3a5ce4b8, devicemanage.repository.appdeploy.entity.Subtask@38848217]
444, 1000000002
3[devicemanage.repository.appdeploy.entity.Subtask@511d5e6e, devicemanage.repository.appdeploy.entity.Subtask@7a78d380]
444, 1000000002
看起来每个
FindBydevicidInAndStateInOrderByIdasc
都提供了一个参数deviceIdList
Array.asList(新字符串[]{“100000002”})
,因此每个查找结果都是设备
100000002
的子任务

DB是postgreSQL 9.4 windows版本,JDBC驱动程序如下

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4-1201-jdbc41</version>
        </dependency>

org.postgresql
postgresql
9.4-1201-jdbc41

我们遗漏了什么吗?

看来您可能遗漏了一个步骤,或者一些没有与读者分享的内容。这个接口的实现来自哪里?你好@JohnAment,谢谢你的回复。在我的问题中,我已经更新了DaoBase接口。但是没有实现SubtaskDao接口。这是Spring数据jpa的查询方法
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.4-1201-jdbc41</version>
        </dependency>