我正在尝试使用本机查询从 postgres DB 中获取树,下一个查询使用 psql 终端可以正常工作:
SELECT col_1 FROM my_tree WHERE parent_id ~ lquery('*.C.*')
但是当我使用实体管理器添加相同的查询时:
private List<String> fetchTreeByParentId() {
Query query = entityManager.createNativeQuery("SELECT col_1 FROM my_tree WHERE parent_id ~ lquery('*.C.*')");
return query.getResultList();
}
我收到下一个错误:
2021-04-28 08:21:51.105 WARN 107978 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42883
2021-04-28 08:21:51.105 ERROR 107978 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : ERROR: function lquery(unknown) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 65
我有一些我错过的东西......也许更新postgresql jar?
该项目是spring boot 2.4.2