-
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数据库中大对象存取演示。
pg-inet-maven.zip,这个包简单地包装了postgresql-${postgresql.version}.jar.postgresql networking extansions用maven重建和增强
Maven坐标:org.postgresql:postgresql:42.3.1; 标签:postgresql、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
postgres quatrz初始化sql...#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
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”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
jar包,官方版本,自测可用
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”文件,即可纵览文档内容。 人性化翻译,文档中的代码和...
postgresql odbc驱动包
postgresql-42.6.0.jar 对 java 8的支持postgresql驱动包
微软企业库EnterpriseLibrary连接PostgreSQL时所需库文件,需要注意微软企业库(Microsoft.Practices.EnterpriseLibrary.Data和Microsoft.Practices.EnterpriseLibrary.Common)版本需要是4.1.0才行,同时需要Npgsql...
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.PostgreSQL.10.2018.1.pdf 很不错的关于postgresql数据库的书籍
Maven坐标:org.postgresql:postgresql:42.3.3; 标签:postgresql、中文文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和结构...
EMS.PostgreSQL.Manager.v2.8.0.1.Pro.rarEMS.PostgreSQL.Manager.v2.8.0.1.Pro.rarEMS.PostgreSQL.Manager.v2.8.0.1.Pro.rar
Maven坐标:org.postgresql:postgresql:42.3.3; 标签:postgresql、中英对照文档、jar包、java; 使用方法:解压翻译后的API文档,用浏览器打开“index.html”文件,即可纵览文档内容。 人性化翻译,文档中的代码和...
postgresql-9.4.1212驱动, driver=org.postgresql.Driver url=jdbc:postgresql://127.0.0.1:5432/test 配置驱动 url 账户密码等, 创建connector即可连接使用, 亲测可用
Packt.Mastering.PostgreSQL.15.5th.Edition.2023.1
Packt.PostgreSQL.Developer's.Guide.2015