I have hierarchical folder structure:
class Folder {
String name;
List<Folder> subfolders;
I want to select all Folders, which are not subfolder. How can I write findAll method/query in jpql like :
SELECT * FROM folder WHERE folder.id NOT IN (
SELECT folder.id FROM folder INNER JOIN folder_folder ON folder.id = folder_folder.folder_id);
I don't have parent field;
something like this?
Folder.findAll("from Folder as folder where folder.id not in subfolders");
Need to change domain to one-to-many; Just add static mappedBy = [subLevels: "parentFolder"]
And findAll method will be