简体   繁体   中英

srid(geometry) function does not exist: Java hibernate

I'm retaking an old project that someone at my university was working on. It is mostly some DB management of geographic data (which is being made in psql, and using postgis 1.5 and 2.0) and some modifications and a GUI made in java netbeans. For the interface between those two, Maven and hibernate is being used.

The deal is, that when I try to run the application that is supposed to be working, I get this errors

SEVERE: ERROR: no existe la función srid(geometry)
Exception in thread "AWT-EventQueue-0" org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    at org.hibernate.engine.query.NativeSQLQueryPlan.performExecuteUpdate(NativeSQLQueryPlan.java:174)
    at org.hibernate.impl.SessionImpl.executeNativeUpdate(SessionImpl.java:1163)
    at org.hibernate.impl.SQLQueryImpl.executeUpdate(SQLQueryImpl.java:334)
    at testdb.ui.NetworkClustering.updateOLTdistance(NetworkClustering.java:609)
    at testdb.ui.MetroClustering.setMetroOltDist(MetroClustering.java:118)
    at testdb.ui.MetroClustering.clusterData(MetroClustering.java:38)
    at com.kipouridis.thesis.GUI.MetroDialog.jButton1ActionPerformed(MetroDialog.java:102)
    at com.kipouridis.thesis.GUI.MetroDialog.access$100(MetroDialog.java:19)
    at com.kipouridis.thesis.GUI.MetroDialog$2.actionPerformed(MetroDialog.java:56)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
    at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
    at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
    at java.awt.Dialog.show(Dialog.java:1082)
    at java.awt.Component.show(Component.java:1651)
    at java.awt.Component.setVisible(Component.java:1603)
    at java.awt.Window.setVisible(Window.java:1014)
    at java.awt.Dialog.setVisible(Dialog.java:1005)
    at com.kipouridis.thesis.GUI.ONUAdmin.calcDistQueryButtonActionPerformed(ONUAdmin.java:219)
    at com.kipouridis.thesis.GUI.ONUAdmin.access$100(ONUAdmin.java:44)
    at com.kipouridis.thesis.GUI.ONUAdmin$2.actionPerformed(ONUAdmin.java:94)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6505)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
    at java.awt.Component.processEvent(Component.java:6270)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4861)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2719)
    at java.awt.Component.dispatchEvent(Component.java:4687)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:708)
    at java.awt.EventQueue$4.run(EventQueue.java:706)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Reaching the break point, I found that the error appear when it reach one update to the DB, following this line:

result = oltDistQ.executeUpdate();

and the query that it is being applied in oltDistQ is the following:

String oltDistQuery = "update connections set oltdist = (select result.distance from "
                + "(select sum( st_length(st_transform(the_geom,2163))) as distance "
                + "from dijkstra_sp_delta('ways' , ( select onu.source from onu where onu.gid = connections.gid  )"
                + " ,    (select rn.source from onu as rn where rn.gid = "
                + "(select olt_id from metro_nets where net_id = connections.metro_net )  ),0.01)) as result   ) "
                + "where metro_net = " + 0;

I've checked the DB and all the columns appear to exists, and as far as I can see, the function srid(geometry) is not being stated in that query. I know that this function was updated and now it is stated as st_srid(geometry) , but what I can't find is where this function is being called or where I can check for it.

I've checked the java files and it appear that in none of them is being used that function within a query update, and for the DB, if the function was being called and psql would have not recognized it, the tables weren't able to be created; but they are created and have the desired data.

There are several amount of line codes (and code files), which I don't know deeply, as I said it's not a project of my own. But I'm losing my hope here, as I don't know where to check to solve this error.

Please, if someone knows something, it would be really really helpful.

Thanks in advance!

The original functions were named, eg srid(geometry) , but these were later renamed with an ST_ prefix (ie, patial ype). YPE)。 To use the originally named functions, find an enabler script that came with your PostGIS installation named legacy.sql (also legacy_minimal.sql may work, but I don't know). These will provide the legacy functions to your database that is expected by older clients.

Use them like this:

psql -d [yourdatabase] -v ON_ERROR_STOP=1 -f legacy.sql

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM