2017-03-15 48 views
0

我試圖從Grails應用程序查詢存儲與postgres ltree類型的物化路徑。不幸的是,我的查詢使用「?」這是由GORM捕獲作爲參數逃跑? (問號)在休眠/ gorm sql限制

sqlRestriction("materialized_path ? (SELECT ARRAY(SELECT CAST(CAST(subpath(?,0,generate_series) AS text) ||'.*{1}' AS lquery) FROM generate_series(1,nlevel(CAST(? AS lquery)))))" 
       ,[vertex.materializedPath,vertex.materializedPath]) 

如果是第一個問號應該逃脫,被拋出的錯誤操作是

org.postgresql.util.PSQLException: No value specified for parameter 4. 
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:246) 
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:272) 
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:430) 
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:356) 
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:168) 
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:116) 
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:70) 

回答

0

與一個小實驗發現它自己。這只是一個雙重問號。所以,

"materialized_path ? (SELECT ARRAY(... 

成爲

"materialized_path ?? (SELECT ARRAY(