我试图像这样执行原始查询:
em.createNativeQuery(
"WITH RECURSIVE recursetree(id, parent_id) AS (\n" +
"SELECT id, parent_g_id FROM group WHERE parent_g_id = 2\n" +
"UNION\n" +
" SELECT t.id, t.parent_g_id\n" +
" FROM group t\n" +
" JOIN recursetree rt ON rt.id = t.parent_g_id\n" +
" )\n" +
"SELECT * FROM recursetree;").getResultList();
在Postgres端(通过PGAdmin)它工作正常,但是从Java它得到以下错误:
java.lang.IllegalArgumentException: argument type mismatch
我做错了什么?如何从Java EE环境中对Postgres执行真正的原始查询?