java Hibernate+PostgreSQL+网络地址类型(inet、cdir)
我已经用Hibernate 4.2.7和PostgreSQL 9.3.1开始了我的示例项目,一切都很顺利
目前我想使用INET PostgreSQL type,但我无法用Hibernate映射它
我遇到了这个休眠错误:无法确定以下列的类型:inet,at table:DEVICE\u IP\u ADDRESS
我使用组织。冬眠地方话PostgreSql方言和hbm。xml配置文件
我的hibernate映射文件:
<property name="ipAddress" type="inet">
<column name="IP_ADDRESS" not-null="true" />
</property>
我问了谷歌,但找不到任何可用的解决方案。 你能帮我吗
谢谢
编辑: 如果我想使用'extra'postgresql类型和PostGIS类型,你认为我需要使用什么样的ORM实现
或者我需要使用简单的JDBC
# 1 楼答案
我只是解决了一个像你这样的问题。关于这件事几乎没有什么消息。正如@ms03所说。。。更好的方法是创建一个新类型和一个实现该类型的类,并处理用于设置/获取数据库的java对象
首先,在实体上,必须为参数声明类型
第二,为java创建新的处理对象,它必须有一个默认的构造,一个从DB处理数据的构造,并且可以序列化
最后一步,您必须创建一个自定义类型
当我从DB中插入或获取一行时,这种方法对我来说很好