Received object of type org.postgresql.util.PGobject

前端 未结 2 421
日久生厌
日久生厌 2021-01-14 00:04

I can insert geometry data into database from my code, but I can only query the data using an SQL editor, like PGAdmin III. I can\'t retrieve geometry data back to my code.

2条回答
  •  长情又很酷
    2021-01-14 01:06

    You need to add Postgis, hibernate-spatial and the other related libs to your Wildfly before deploying your application, this is because the hibernate that you are using is the bundled with the wildfly but the other libraries are bundled with your war, so they are using different classloaders.

    If you check this code you can see that the cast is correct, and the error message make no sense, this is tipically a issue with classloaders.

    To fix this issue you need to add all libs to your wildfly, to do this you can do:

    cd $JBOSS_PATH/modules/system/layers/base/org/hibernate/main
    mvn dependency:copy -Dartifact=org.hibernate:hibernate-spatial:5.0.7.Final:jar -DoutputDirectory=.
    mvn dependency:copy -Dartifact=org.geolatte:geolatte-geom:1.0.1:jar -DoutputDirectory=.
    mvn dependency:copy -Dartifact=com.vividsolutions:jts:1.13:jar -DoutputDirectory=.
    

    Edit the module.xml file to add your deps:

    
    
    
    

    And in the dependencies tag, add:

    
    

    Also if you are using postgresql, you need to add in the dependencies tag:

    
    

    Use the correct version in the mvn command to download the correct jar.

提交回复
热议问题