Hi ,
I can explain the problem with a simple example
We can use the query
"WITH LINK(ID, NAME, LEVEL) AS (
SELECT ID, NAME, 0 FROM FOLDER WHERE PARENT IS NULL
UNION ALL
SELECT FOLDER.ID, IFNULL(LINK.NAME || '/', '') || FOLDER.NAME, LEVEL + 1
FROM LINK INNER JOIN FOLDER ON LINK.ID = FOLDER.PARENT
) SELECT NAME FROM LINK WHERE NAME IS NOT NULL ORDER BY ID;"
that is available in the URL :
I have a DAO that has the following method
@SqlQuery("WITH LINK(ID, NAME, LEVEL) AS (SELECT ID, NAME, 0 FROM FOLDER WHERE PARENT IS NULL UNION ALL SELECT
FOLDER.ID, IFNULL(
LINK.NAME || '/', '') ||
FOLDER.NAME, LEVEL + 1 FROM LINK INNER JOIN FOLDER ON
LINK.ID = FOLDER.PARENT AND
LINK.ID < :id
)SELECT NAME FROM LINK WHERE NAME IS NOT NULL ORDER BY ID;")
List<Folder> getFolders(@Bind("id") long id);
i have got the corresponding FolderMapping class and POJO Folder
However the id not not bound to the sqlQuery object,
that is when i call
List<Folder> treeNodes = dao.getFolders(4);
the result is empty. However when i just replace the :id with constant value 4 in the query the same method call provide me the desired result
ie the bind value is not injected in to sqlquery object.
Your advice on resolving this issue will be very much helpful
Regards,
Bala