greenDAO
greenDAO copied to clipboard
Exception on raw query
I'm trying to fetch the parent hierarchy of a given Department with the query below. Probably this is something GreenRobot can't handle. Is there any alternatives to run a pure SQL
query in this library?
mDaoSession.getPlaceDepartmentItemDao().queryRawCreate("" +
";WITH CTE AS " +
"(" +
"SELECT a.PID, a.ID, a.LEVEL, a.NAME " +
"FROM PLACE_DEPARTMENT_ITEM a " +
" WHERE ID = ?" +
"UNION ALL " +
"SELECT a.PID, a.ID, a.LEVEL, a.NAME " +
"FROM PLACE_DEPARTMENT_ITEM a " +
"JOIN cte c ON c.PID = a.ID" +
")" +
"SELECT * FROM CTE ORDER BY CTE.LEVEL DESC", departmentId)
.list();
GreenDao throws the following exception:
java.lang.IllegalArgumentException: Cannot bind argument at index 1 because the index is out of range. The statement has 0 parameters.