我在PostgreSQL中有一个text[]列类型。
我正在尝试做这件事。
public interface MyUserRepo extends CrudRepository<MyUser, String> {
@Query(value = "SELECT * FROM my_user x WHERE x.tenant_ids @> ARRAY[':tenantId'] AND x.roles @> ARRAY['driver']", nativeQuery = true)
Set<MyUser> findDrivers(String tenantId);
}
我的问题是参数没有被替换。我猜测这是因为单引号的原因。
我尝试使用
@Param("tenant_id")
,但没有起作用。还尝试使用索引参数,例如
?1
。
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: text[] @> character varying[] Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
- undefined