-
org.postgresql.util.PSQLException: ERROR: column "pwd" is of type hstor0
org.springframework.jdbc.BadSqlGrammarException:
### Error updating database. Cause: org.postgresql.util.PSQLException: ERROR: column "pwd" is of type hstore but expression is of type character varying
建议:You will need to rewrite or cast the expression.
位置:56
### The error may exist in file [D:\SystemFile\eclipseWorkspace\springMybatisPostgresql\build\classes\com\abin\lee\template\spring\dao\AnimalMapper.xml]
### The error may involve com.abin.lee.template.spring.dao.AnimalMapper.insert-Inline
### The error occurred while setting parameters
### SQL: insert into animal (id, name, pwd) values (?, ?, ?)
### Cause: org.postgresql.util.PSQLException: ERROR: column "pwd" is of type hstore but expression is of type character varying
建议:You will need to rewrite or cast the expression.
位置:56
; bad SQL grammar []; nested exception is org.postgresql.util.PSQLException: ERROR: column "pwd" is of type hstore but expression is of type character varying
建议:You will need to rewrite or cast the expression.
位置:56
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:231)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:368)
at $Proxy17.insert(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.insert(SqlSessionTemplate.java:240)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:46)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
at $Proxy18.insert(Unknown Source)
at com.abin.lee.template.spring.aninal.test.CreateAnimalTest.testCreateAnimal(CreateAnimalTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:232)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:89)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:175)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.postgresql.util.PSQLException: ERROR: column "pwd" is of type hstore but expression is of type character varying
建议:You will need to rewrite or cast the expression.
位置:56
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2161)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1890)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:410)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at org.apache.commons.dbcp.DelegatingPreparedStatement.execute(DelegatingPreparedStatement.java:172)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:55)
at $Proxy20.execute(Unknown Source)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.update(PreparedStatementHandler.java:41)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.update(RoutingStatementHandler.java:66)
at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:45)
at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:100)
at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:148)
at org.apache.ibatis.session.defaults.DefaultSqlSession.insert(DefaultSqlSession.java:137)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
... 34 more
我现在使用postgresql的时候,使用到了hstore类型的字段,现在遇到一个问题,我用mybatis做映射的时候,实体类对应的字段pwd的类型是hstore类型,而在映射文件里面,AnimalMapper.xml里面pwd对应的jdbcType=Varchar,一直报错搞不定,希望给与帮助!!,在此谢过
问题补充:package com.abin.lee.template.spring.pojo.po;
public class Animal {
private Long id;
private String name;
private String pwd;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
}
AnimalMapper.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.abin.lee.template.spring.dao.AnimalMapper" >
<resultMap id="BaseResultMap" type="com.abin.lee.template.spring.pojo.po.Animal" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="name" property="name" jdbcType="VARCHAR" />
<result column="pwd" property="pwd" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, name, pwd
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
select
<include refid="Base_Column_List" />
from animal
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
delete from animal
where id = #{id,jdbcType=BIGINT}
</delete>
<insert id="insert" parameterType="com.abin.lee.template.spring.pojo.po.Animal" >
<selectKey order="BEFORE" keyProperty="id" resultType="java.lang.Long">
SELECT nextval('animal_id_seq') as id
</selectKey>
insert into animal (id, name, pwd)
values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{pwd,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.abin.lee.template.spring.pojo.po.Animal" >
insert into animal
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="id != null" >
id,
</if>
<if test="name != null" >
name,
</if>
<if test="pwd != null" >
pwd,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="id != null" >
#{id,jdbcType=BIGINT},
</if>
<if test="name != null" >
#{name,jdbcType=VARCHAR},
</if>
<if test="pwd != null" >
#{pwd,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.abin.lee.template.spring.pojo.po.Animal" >
update animal
<set >
<if test="name != null" >
name = #{name,jdbcType=VARCHAR},
</if>
<if test="pwd != null" >
pwd = #{pwd,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.abin.lee.template.spring.pojo.po.Animal" >
update animal
set name = #{name,jdbcType=VARCHAR},
pwd = #{pwd,jdbcType=VARCHAR}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>2014年4月12日 21:50
目前还没有答案
相关推荐
在PostgreSQL数据库系统中,"大对象"(Large Objects)是一种专门用于存储和管理超大数据量数据类型的功能,如图像、视频或大型文本文件。大对象不同于普通的行内存储的数据,因为它们可能超过单个列的大小限制。...
Maven坐标:org.postgresql:postgresql:42.3.1; 标签:postgresql、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
Maven坐标:org.postgresql:postgresql:42.2.5; 标签:postgresql、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和...
Maven坐标:org.postgresql:postgresql:42.2.6; 标签:postgresql、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
postgresql-42.6.0.jar 对 java 8的支持postgresql驱动包
postgres quatrz初始化sql...#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
PostgreSQL社区于2020年10月17日发布JDBC紧急修复版本v42.2.18。该版本主要修复了42.2.17版本中并未完全修复的gssEncMode问题。
Maven坐标:org.postgresql:postgresql:42.2.2; 标签:postgresql、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和...
driver-class-name: org.postgresql.Driver ``` 此外,还需要添加 Druid 配置,以便监控数据库连接池的状态: ```properties spring: datasource: validationQuery: SELECT 1 ``` 3. PostgreSQL 集成 集成 ...
pg-inet-maven.zip,这个包简单地包装了postgresql-${postgresql.version}.jar.postgresql networking extansions用maven重建和增强
这段代码首先加载了`org.postgresql.Driver`类(即PostgreSQL的JDBC驱动),然后通过`DriverManager.getConnection()`方法建立了一个到指定数据库的连接。 **4. 执行SQL语句** 有了连接后,可以使用`Statement`或`...
postgresql-42.5.0.jar是Java上的一个驱动程序,用于连接PostgreSQL数据库并与其进行交互。它可以让Java程序员方便地使用PostgreSQL数据库,并提供了许多功能和工具,使程序员可以编写高效、稳定和高性能的应用程序...
2. **配置文件**:PostgreSQL的配置主要通过`postgresql.conf`文件进行,包括设置最大并发连接数、缓存大小等关键参数。 3. **服务管理**:在Windows下,可以通过服务管理器启动、停止或重启PostgreSQL服务。 ####...
工具连接postgresql需要的jar包
Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection(url, user, password); // ... 执行你的数据库操作 } catch (Exception e) { e.printStackTrace(); } } } ``` ...
Maven坐标:org.postgresql:postgresql:42.3.3; 标签:postgresql、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
Maven坐标:org.postgresql:postgresql:42.2.2; 标签:postgresql、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
Mastering PostgreSQL 15 Mastering PostgreSQL 15是Packt Publishing发布的一本关于PostgreSQL的书籍,旨在帮助读者掌握高级技术,构建和管理可扩展、可靠、容错的数据库应用程序。下面是从这本书中提取的一些重要...
Table of Contents Chapter 1. PostgreSQL Versions Chapter 2. Database Hardware Chapter 3. Database Hardware Benchmarking Chapter 4. Disk Setup Chapter 5. Memory for Database Caching Chapter 6. Server ...
《Packt.Mastering.PostgreSQL10》是一本专注于PostgreSQL数据库开发与管理的专业书籍,由Hans-Jürgen Schönig编写。这本书涵盖了PostgreSQL 10版本的高级技术,适合数据库开发者和管理员深入学习和实践。书籍详细...