PostGIS Geometry saving: “Invalid endian flag value encountered.”

后端 未结 5 1705
广开言路
广开言路 2020-12-07 01:05

I have a Spring Roo + Hibernate project which takes a JTS well-known text (WKT) String input from the client application, converts it into a JTS Geometry object, and then at

5条回答
  •  無奈伤痛
    2020-12-07 01:39

    The solution seems to be the following:
    @Column to map the field to the desired column with JPA annotations
    @Type to specify the Hibernate mapping with the dialect.

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

    You could add the Hibernate property inside the hibernate.cfg.xml file to see the db request and try to catch the string-encoded problem with a text based editor like Notepad++ with "UTF-8"/"ANSI"/"other charsets"

    
    true
    true
    true
    

    To add the hibernate properties you will have an hibernate.cfg.xml file with the following stuff. Don't copy/paste it because it is MySQL oriented. Just look where I have inserted the properties I evocated previously.

     
     
     
          
               true
               com.mysql.jdbc.Driver
               db-password
               jdbc:mysql://localhost:3306/db-name
               db-username
               pojo
               org.hibernate.dialect.MySQL5InnoDBDialect
               true
               false
               **true**
               false
    
               
               
    
          
     
    

    Another way to log all sql is to add package specific properties inside a log4j.properties file:

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

    Good luck!

提交回复
热议问题