postgresql报错:Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint =

131 篇文章 1 订阅

Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: bigint = character varying 建议:No operator matches the given name and argument types. You might need to add explicit type casts.

如何解决?

在 PostgreSQL 中,当你遇到错误消息 ERROR: operator does not exist: bigint = character varying 时,这通常意味着你在进行比较操作时,左右两个操作数的数据类型不匹配。在你的情况下,左边是 bigint 类型,右边是 character varying(即字符串)类型,因此 PostgreSQL 无法执行比较。

  1. 修改数据库模型
    如果数据模型允许,考虑将数据库中的相应列的数据类型调整为统一类型,以减少以后的类型冲突。

  2. 更改查询逻辑
    如果可能,最好是在应用逻辑中确保将值转换为相同类型,以避免潜在的性能问题和类型错误。例如,确保在查询中使用 bigint 进行比较:

    SELECT * FROM your_table WHERE your_bigint_column = CAST(your_varchar_column AS bigint);

使用ORM Bee操作postgresql

1. 添加配置信息(在bee.properties)

bee.db.driverName =org.postgresql.Driver
bee.db.url =jdbc:postgresql://127.0.0.1:5432/bee
bee.db.username =Administrator
bee.db.password =

2. pom.xml添加依赖

		<dependency>
			<groupId>org.teasoft</groupId>
			<artifactId>bee-all</artifactId>
			<version>2.4.0</version>
		</dependency>

		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<version>42.2.24.jre7</version>
		</dependency>

3. 写java代码:

import java.util.List;

import org.teasoft.bee.osql.BeeException;
import org.teasoft.bee.osql.api.SuidRich;
import org.teasoft.exam.comm.Printer;
import org.teasoft.honey.osql.shortcut.BF;

public class BeeExam {

	public static void main(String[] args) {
		try {
			SuidRich suidRich = BF.getSuidRich();
			List<Clazz> list = suidRich.select(new Clazz(), 0, 2);
			Printer.printList(list);
		} catch (BeeException e) {
			//...
		}
	}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值