栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

PostGIS Geometry保存:“遇到无效的字节序标志值。”

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

PostGIS Geometry保存:“遇到无效的字节序标志值。”

解决方案似乎如下:

@Column
使用JPA批注将字段映射到所需的列,
@Type
以使用方言指定Hibernate映射。

@Column(columnDefinition = "Geometry", nullable = true) @Type(type = "org.hibernate.spatial.GeometryType")public Point centerPoint;

您可以在hibernate.cfg.xml文件中添加Hibernate属性,以查看db请求,并尝试使用基于文本的编辑器(例如Notepad ++,带有“UTF-8” /“ ANSI” /“其他字符集”)捕获字符串编码的问题。

<!--hibernate.cfg.xml --><property name="show_sql">true</property><property name="format_sql">true</property><property name="use_sql_comments">true</property>

要添加hibernate属性,您将拥有一个hibernate.cfg.xml文件,其中包含以下内容。不要复制/粘贴它,因为它是面向MySQL的。只需看看我在前面插入的属性的位置即可。

 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration>      <session-factory><property name="hibernate.bytepre.use_reflection_optimizer">true</property><property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property><property name="hibernate.connection.password">db-password</property><property name="hibernate.connection.url">jdbc:mysql://localhost:3306/db-name</property><property name="hibernate.connection.username">db-username</property><property name="hibernate.default_entity_mode">pojo</property><property name="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property><property name="hibernate.format_sql">true</property><property name="hibernate.search.autoregister_listeners">false</property>**<property name="hibernate.show_sql">true</property>**<property name="hibernate.use_sql_comments">false</property><mapping ressource="...." /><!-- other hbm.xml mappings below... -->      </session-factory> </hibernate-configuration>

记录所有sql的另一种方法是在log4j.properties文件内添加特定于包的属性:

log4j.logger.org.hibernate.SQL=DEBUGlog4j.logger.org.hibernate.type=TRACE

祝好运!



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/393120.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号