PostgreSQL到Java数据类型(Grails)
发布时间:2020-12-13 16:08:49 所属栏目:百科 来源:网络整理
导读:我有以下(Grails)域对象: class Country {Integer idchar country_abbrString country_namestatic mapping = { version false id name: 'id' table 'country' id generator:'identity',column:'id'}static constraints = {}} ‘country table’中的’countr
我有以下(Grails)域对象:
class Country { Integer id char country_abbr String country_name static mapping = { version false id name: 'id' table 'country' id generator:'identity',column:'id' } static constraints = { }} ‘country table’中的’country_abbr’字段的类型为:character(2).但是,每当我将域对象的数据类型(对于’country_abbr’)设置为String时,初始化失败,并出现以下异常 org.hibernate.HibernateException: Wrong column type in mydb.country for column country_abbr. Found: bpchar,expected: varchar(255) 另一方面,将此类型保留为Java char只会检索第一个字符.任何想法我如何映射到这种类型?另外,究竟什么是bpchar? 谢谢 解决方法
只是为了回答这个问题.解决方案是更改country_abbr映射:
country_abbr columnDefinition: 'char' 参考here. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |