简体   繁体   English

引起:org.postgresql.util.PSQLException:错误:运算符不存在:文本= integer

[英]Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer

I have code like this:我有这样的代码:

for (Integer partiesId : request.getPartiesIds()) {
            System.out.println(partiesId);
            Optional<Parties> parties = partiesRepository.findById(partiesId);
            OrderPartiesList.add(new OrderParties(Order.get(), parties.get()));
        }

here my request这是我的要求

like this像这样

{
    "purchaseId" : 8,
    "partiesIds": [1, 2, 3, 4]
}

but when i hit my API i got error like this但是当我点击我的 API 时,我得到了这样的错误

Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer

i have check my repository use this我已经检查了我的存储库使用这个

public interface PartiesRepository extends JpaRepository<Parties, Integer>, JpaSpecificationExecutor<Parties> {
   // @Query("select p from parties p where p.name =?1")
    List<Parties> findAllByName(String name);
}

my model entity for parties also have use @Id with variable Integer my question why i getting error like that?我的 model 实体也使用带有变量 Integer 的 @Id 我的问题为什么我会出现这样的错误?

You are comparing an integer with a varchar when invoking partiesRepository.findById(partiesId);在调用partiesRepository.findById(partiesId); partiesId is an int, but in the DB it's probably a varchar. partyId 是一个 int,但在数据库中它可能是一个 varchar。 You could try something like partiesRepository.findById(String.valueOf(partiesId));您可以尝试类似partiesRepository.findById(String.valueOf(partiesId)); but probably you should change your ID field in the DB to be an int.但可能您应该将数据库中的 ID 字段更改为 int。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 org.postgresql.util.PSQLException:错误:运算符不存在:integer = bytea - org.postgresql.util.PSQLException: ERROR: operator does not exist: integer = bytea 如何解决“Caused by: org.postgresql.util.PSQLException: ERROR: relation “employee” does not exist Position: 13”错误? - How to resolve "Caused by: org.postgresql.util.PSQLException: ERROR: relation "employee" does not exist Position: 13" error? 由以下原因引起:org.postgresql.util.PSQLException:错误:类型“枚举”不存在 - Caused by: org.postgresql.util.PSQLException: ERROR: type “enum” does not exist org.postgresql.util.PSQLException:错误:关系“序列”不存在 - org.postgresql.util.PSQLException: ERROR: relation “sequence” does not exist org.postgresql.util.PSQLException:错误:关系“产品”不存在 - org.postgresql.util.PSQLException: ERROR: relation "products" does not exist org.postgresql.util.PSQLException:错误:运算符不存在:bigint = bytea - org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = bytea 引起:org.postgresql.util.PSQLException:错误:列 performanc3_.app_user_internal_user_id 不存在 - Caused by: org.postgresql.util.PSQLException: ERROR: column performanc3_.app_user_internal_user_id does not exist 引起:org.postgresql.util.PSQLException:错误:“:”处或附近的语法错误 - Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near ":" org.postgresql.util.PSQLException:致命:数据库“ postgres&gt;”不存在 - org.postgresql.util.PSQLException: FATAL: database “postgres>” does not exist org.postgresql.util.PSQLException:错误:列 systementi0_.id 不存在 - Hibernate、PostgreSql - org.postgresql.util.PSQLException: Error: column systementi0_.id does not exist - Hibernate, PostgreSql
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM