[英]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.