Hibernate 5.2.17:ORA-01797:此运算符后必须跟有 ANY 或 ALL
Hibernate 5.2.17: ORA-01797: this operator must be followed by ANY or ALL
我有一个 Oracle 18.4.0 XE 数据库,我正尝试从 JPA 2.1 访问它,该数据库由 Hibernate 5.2.17 实现。
我在 2 个实体之间有 ManyToMany
连接:
public class PermissionEntity implements Serializable {
private static final long serialVersionUID = -3862680194592486778L;
@Id
@GeneratedValue
private Long id;
@Column(unique = true)
private String permission;
@ManyToMany
private List<RoleEntity> roles;
}
public class RoleEntity implements Serializable {
private static final long serialVersionUID = 8037069621015090165L;
@Column(unique = true)
private String name;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
private List<PermissionEntity> permissions;
}
当尝试 运行 PermissionRepository 上的 Spring Data JPA 请求时:findAllByPermission(Iterable<String> permissions)
,出现以下异常:
Error : 1797, Position : 140, Sql = select permission0_.id as id1_0_, permission0_.permission as permission2_0_ from PermissionEntity permission0_ where permission0_.permission=(:1 , :2 ), OriginalSql = select permission0_.id as id1_0_, permission0_.permission as permission2_0_ from PermissionEntity permission0_ where permission0_.permission=(? , ?), Error Msg = ORA-01797: this operator must be followed by ANY or ALL
使用'in'关键字:findAllByPermissionIn(Iterable<String> permissions)
.
这会产生这样的查询:where permission0_.permission IN (:permissions)
。
您要让 Spring 数据 Jpa 引擎搜索 Permission
,其中权限等于列表。它应该使用 IN 运算符,因此您的方法名称应该是:
findAByPermissionIn(Iterable<String> permissions)
我有一个 Oracle 18.4.0 XE 数据库,我正尝试从 JPA 2.1 访问它,该数据库由 Hibernate 5.2.17 实现。
我在 2 个实体之间有 ManyToMany
连接:
public class PermissionEntity implements Serializable {
private static final long serialVersionUID = -3862680194592486778L;
@Id
@GeneratedValue
private Long id;
@Column(unique = true)
private String permission;
@ManyToMany
private List<RoleEntity> roles;
}
public class RoleEntity implements Serializable {
private static final long serialVersionUID = 8037069621015090165L;
@Column(unique = true)
private String name;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private Long id;
@ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles")
private List<PermissionEntity> permissions;
}
当尝试 运行 PermissionRepository 上的 Spring Data JPA 请求时:findAllByPermission(Iterable<String> permissions)
,出现以下异常:
Error : 1797, Position : 140, Sql = select permission0_.id as id1_0_, permission0_.permission as permission2_0_ from PermissionEntity permission0_ where permission0_.permission=(:1 , :2 ), OriginalSql = select permission0_.id as id1_0_, permission0_.permission as permission2_0_ from PermissionEntity permission0_ where permission0_.permission=(? , ?), Error Msg = ORA-01797: this operator must be followed by ANY or ALL
使用'in'关键字:findAllByPermissionIn(Iterable<String> permissions)
.
这会产生这样的查询:where permission0_.permission IN (:permissions)
。
您要让 Spring 数据 Jpa 引擎搜索 Permission
,其中权限等于列表。它应该使用 IN 运算符,因此您的方法名称应该是:
findAByPermissionIn(Iterable<String> permissions)