Having issues creating edit button that populates MySql Database

At this moment in time I’m able to edit the grid row but it does not save and populate the database, was wondering if anyone had any thoughts on what I could improve?

RolelistService:

package com.CD6113.FinalYear.SynopticProject.Backend;


import org.jboss.logging.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.management.relation.Role;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;


@Component
public class RolelistService {


    RolelistService rolelistService;
    //  private RolelistService rolelistService;


    private Roles Roles;

    @Autowired(required = false)
    private JdbcTemplate jdbcTemplate;

    public List<Roles> findAll() {
        try {
            return jdbcTemplate.query(
                    "SELECT roleid, roleName, clientName, chargeable, primaryContact, roleDescription, careerLevel, skillsRequired FROM rolelist",
                    (ResultSet rs, int rowNum) -> new Roles(rs.getString("roleId"),
                            rs.getString("roleName"), rs.getString("clientName"), rs.getString("chargeable"), rs.getString("primaryContact"), rs.getString("roleDescription"), rs.getString("careerLevel"), rs.getString("skillsRequired")));
        } catch (
                Exception e) {
            return new ArrayList<Roles>();
        }
    }



    public List<Roles> findByRoleId(String RoleID) {
        try {
            return jdbcTemplate.query("SELECT roleName, clientName, chargeable, primaryContact, roleDescription, careerLevel, skillsRequired WHERE roleId=?",
                    new Object[]{RoleID},
                    (ResultSet rs, int rowNum) -> new Roles(rs.getString("roleId"),rs.getString("roleName"), rs.getString("clientName"), rs.getString("chargeable"), rs.getString("primaryContact"), rs.getString("roleDescription"), rs.getString("careerLevel"), rs.getString("skillsRequired")));
        } catch (Exception e) {
            return new ArrayList<Roles>();
        }
    }


    public int update(Roles Role) {
        try {
            return jdbcTemplate.update(
                    "UPDATE rolelist SET, roleName=?, clientName=?, chargeable=?, primaryContact=?, roleDescription=?, careerLevel=?, skillsRequired=? WHERE roleId=?",
                    Role.getRoleId(), Role.getRoleName(), Role.getClientName(), Role.getChargeable(), Role.getPrimaryContact(), Role.getRoleDescription(), Role.getCareerLevel(), Role.getSkillsRequired(), Role.getRoleId());
        } catch (Exception e) {
            return 0;
        }
    }

    public int insert(Roles Role) {
        try {
            return jdbcTemplate.update("INSERT INTO rolelist VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
                    Role.getRoleId(), Role.getRoleName(), Role.getClientName(), Role.getChargeable(), Role.getPrimaryContact(), Role.getRoleDescription(), Role.getCareerLevel(), Role.getSkillsRequired());
        } catch (Exception e) {
            return 0;
        }

    }

    public int saveRole(Roles Role) {
        List<Roles> Roles = this.findByRoleId(Role.getRoleId());
        if (Roles.size() > 0) {
            return update(Role);
        } else {
            return insert(Role);
        }
    }

    public int editRole(Roles Role){
        List<Roles> Roles = this.findByRoleId(Role.getRoleId());
        if (Roles.isEmpty()) {
            return 0;
        } else {
            return update(Role);
        }
    }

    public int deleteRole(Roles Role) {
        try {
            return jdbcTemplate.update("DELETE FROM rolelist WHERE roleId=?",
                    Role.getRoleId());
        } catch (Exception e) {
            return 0;
        }

    }


    //  public Roles findAll(String value) {
    //    return null;
    //}

}

AdminView:

package com.CD6113.FinalYear.SynopticProject.Ui;


import com.CD6113.FinalYear.SynopticProject.Backend.BackendService;
import com.CD6113.FinalYear.SynopticProject.Backend.EmployeeService;
import com.CD6113.FinalYear.SynopticProject.Backend.RolelistService;
import com.CD6113.FinalYear.SynopticProject.Backend.Roles;

import com.CD6113.FinalYear.SynopticProject.MainView;
import com.vaadin.flow.component.grid.editor.Editor;
import com.vaadin.flow.component.textfield.TextArea;
import org.springframework.beans.factory.annotation.Autowired;


import com.vaadin.flow.component.AbstractField;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.formlayout.FormLayout;
import com.vaadin.flow.component.grid.Grid;
import com.vaadin.flow.component.grid.GridVariant;
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.notification.Notification;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.splitlayout.SplitLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.binder.Binder;
import com.vaadin.flow.router.AfterNavigationEvent;
import com.vaadin.flow.router.AfterNavigationObserver;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;

import java.util.Collection;
import java.util.Collections;
import java.util.WeakHashMap;


@Route(value = "adminview", layout = MainView.class)
@PageTitle("Admin-View")
@CssImport("/styles/views/admin-view.css")
public class AdminView extends Div implements AfterNavigationObserver {

    @Autowired
    private BackendService service;

    @Autowired
    private RolelistService rolelistService;

    public Grid<Roles> Role;



    TextField roleId=new TextField();
    TextField roleName= new TextField();
    TextField clientName=new TextField();
    TextField chargeable =new TextField();
    TextField primaryContact=new TextField();
    TextArea roleDescription=new TextArea();
    TextField careerLevel=new TextField();
    TextField skillsRequired=new TextField();
    Button save=new Button("Save");
    Button delete=new Button("Delete");
    Button cancel =new Button("Cancel");



    public Binder<Roles> binder;


    TextField filter = new TextField();


    public AdminView() {
        setId("master-detail-view");
        // Configure Grid
        Role = new Grid<>();
        Role.addThemeVariants(GridVariant.LUMO_NO_BORDER);
        Role.setHeightFull();
        Role.addColumn(Roles::getRoleId).setHeader("Role ID").setAutoWidth(true);
        Role.addColumn(Roles::getRoleName).setHeader("Role Name").setAutoWidth(true);
        Role.addColumn(Roles::getClientName).setHeader("Client Name").setAutoWidth(true);
        Role.addColumn(Roles::getChargeable).setHeader("Chargeable").setAutoWidth(true);
        Role.addColumn(Roles::getPrimaryContact).setHeader("Primary Contact").setAutoWidth(true);
        Role.addColumn(Roles::getRoleDescription).setHeader("Role Description").setAutoWidth(true);
        Role.addColumn(Roles::getCareerLevel).setHeader("Career Level").setAutoWidth(true);
        Role.addColumn(Roles::getSkillsRequired).setHeader("Skills Required").setAutoWidth(true);

        /*Grid.Column<Roles> RoleID = Role.addColumn(Roles::getRoleId).setHeader("Role ID").setAutoWidth(true);
        Grid.Column<Roles> RoleName = Role.addColumn(Roles::getRoleName).setHeader("Role Name").setAutoWidth(true);
        Grid.Column<Roles> ClientName = Role.addColumn(Roles::getClientName).setHeader("Client Name").setAutoWidth(true);
        Grid.Column<Roles> Chargeable = Role.addColumn(Roles::getChargeable).setHeader("Chargeable").setAutoWidth(true);
        Grid.Column<Roles> PrimaryContact = Role.addColumn(Roles::getPrimaryContact).setHeader("Primary Contact").setAutoWidth(true);
        Grid.Column<Roles> RoleDescription = Role.addColumn(Roles::getRoleDescription).setHeader("Role Description").setAutoWidth(true);
        Grid.Column<Roles> CareerLevel = Role.addColumn(Roles::getCareerLevel).setHeader("Career Level").setAutoWidth(true);
        Grid.Column<Roles> SkillsRequired = Role.addColumn(Roles::getSkillsRequired).setHeader("Skills Required").setAutoWidth(true);*/



        //when a row is selected or deselected, populate form
        Role.asSingleSelect().addValueChangeListener(event -> populateForm(event.getValue()));

        // Configuring Form
        binder = new Binder<>(Roles.class);
        Editor<Roles> editor = Role.getEditor();
        editor.setBinder(binder);
        editor.setBuffered(true);

        // Automatically binding fields
        binder.bindInstanceFields(this);





        binder.setBean(new Roles());

        // the grid valueChangeEvent will clear the form too
        cancel.addClickListener(e -> Role.asSingleSelect().clear());

        save.addClickListener(e -> {
            Roles role = binder.getBean();
            if ( rolelistService.saveRole(role) > 0) {
                Role.setItems(rolelistService.findAll());

            } else {
                Notification.show("Save error");
            }
        });

        delete.addClickListener(e -> {
            Roles role = binder.getBean();
            if ( rolelistService.deleteRole(role) > 0) {
                Role.setItems(rolelistService.findAll());

            } else {
                Notification.show("Delete error");
            }
        });



      //  Runnable bindIdTextfield = () -> binder.forField(roleId).bind("RoleId");



       // Runnable bindIdColumn = () -> binder.forField(RoleID).bind("RoleId");

        Collection<Button> editingButtons = Collections.newSetFromMap(new WeakHashMap<>());

        Grid.Column<Roles> editorColumn = Role.addComponentColumn(Roles -> {

            Button edit = new Button("Edit");
            edit.addClassName("edit");
            edit.addClickListener(e -> {
                editor.editItem(Roles);
                roleId.focus();

            });
            edit.setEnabled(!editor.isOpen());
            editingButtons.add(edit);
            return edit;

            });

        editor.addOpenListener(e -> editingButtons.stream()
                .forEach(button -> button.setEnabled(!editor.isOpen())));
        editor.addCloseListener(e -> editingButtons.stream()
                .forEach(button -> button.setEnabled(!editor.isOpen())));

        Button Save = new Button("Save", e -> editor.save());
        Save.addClassName("Save");

        Button Cancel = new Button("Cancel", e -> editor.cancel());
        Cancel.addClassName("Cancel");

        Role.getElement().addEventListener("keyup", event -> editor.cancel()).setFilter("event.key === 'Escape' || event.key === 'Esc'");

        Div Buttons = new Div(Save,Cancel);
        editorColumn.setEditorComponent(Buttons);

        editor.addSaveListener(e -> {
            Roles role = binder.getBean();
            if (rolelistService.editRole(role) > 0) {
                Role.setItems(rolelistService.findAll());

            } else {
                Notification.show("Save error");
            }
        });






        SplitLayout splitLayout = new SplitLayout();
        splitLayout.setSizeFull();

        createGridLayout(splitLayout);
        createEditorLayout(splitLayout);

        add(splitLayout);



    }

    private void createEditorLayout(SplitLayout splitLayout) {
        Div editorDiv = new Div();
        editorDiv.setId("editor-layout");
        FormLayout formLayout = new FormLayout();
        addFormItem(editorDiv, formLayout, roleId, "Role ID");
        addFormItem(editorDiv, formLayout, roleName, "Role Name");
        addFormItem(editorDiv, formLayout, clientName, "Client Name");
        addFormItem(editorDiv, formLayout, chargeable, "Chargeable");
        addFormItem(editorDiv, formLayout, primaryContact, "Primary Contact");
        addFormItem(editorDiv, formLayout, roleDescription, "Role Description");
        addFormItem(editorDiv, formLayout, careerLevel, "Career Level");
        addFormItem(editorDiv, formLayout, skillsRequired, "Skills Required");



        createButtonLayout(editorDiv);
        splitLayout.addToSecondary(editorDiv);
    }



    private void createButtonLayout(Div editorDiv) {
        HorizontalLayout buttonLayout = new HorizontalLayout();
        buttonLayout.setId("button-layout");
        buttonLayout.setWidthFull();
        buttonLayout.setSpacing(true);
        cancel.addThemeVariants(ButtonVariant.LUMO_TERTIARY);
        save.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
        delete.addThemeVariants(ButtonVariant.LUMO_ERROR);
        buttonLayout.add(delete, cancel, save);
        editorDiv.add(buttonLayout);
    }


    private void createGridLayout(SplitLayout splitLayout) {
        Div wrapper = new Div();
        wrapper.setId("wrapper");
        wrapper.setWidthFull();
        splitLayout.addToPrimary(wrapper);
        wrapper.add(Role);
    }

    private void addFormItem(Div wrapper, FormLayout formLayout, AbstractField field, String fieldName) {
        formLayout.addFormItem(field, fieldName);
        wrapper.add(formLayout);
        field.getElement().getClassList().add("full-width");
    }

    @Override
    public void afterNavigation(AfterNavigationEvent event) {

        // Lazy init of the grid items, happens only when we are sure the view will be
        // shown to the user
        //employees.setItems(service.getEmployees());
        Role.setItems(rolelistService.findAll());
    }



    private void populateForm(Roles value) {
        // Value can be null as well, that clears the form

        //binder.readBean(value); // commented out
        if ( value == null ) {
            value = new Roles();
        }
        binder.setBean(value);


    }
}