@Override public void saveCategory(CategoryData categoryData) { if (categoryData.getParentCategory() == null) categoryService.addCategory(categoryData.getCategoryEntity()); else { Category parent = categoryService.find(UUIDHelper.stringToUUID(categoryData.getParentCategory().getUuid())); Category child = new Category( UUIDHelper.stringToUUID(categoryData.getUuid()), categoryData.getCategoryName(), parent); categoryService.addCategory(child); categoryService.addParentCategory( child.getUuid(), UUIDHelper.stringToUUID(categoryData.getParentCategory().getUuid())); } }