How to use insert ebean from repository and not directly in controller please!

Hello everybody,

Can i use the method insert ebean written in my repository folder to import data from EXCEL to Database without initializing and injecting again ( EbeanConfig import ) in my controller ?

Thank you so much in advance :slight_smile:

PointageRepository.java

    public CompletionStage<Long> insert(Pointage pointage) {
        return supplyAsync(() -> {
             ebeanServer.insert(pointage);
             return pointage.id;
        }, executionContext);
    }

PointageController.java

    public CompletionStage<Result> save() {
        Form<Pointage> pointageForm = formFactory.form(Pointage.class).bindFromRequest();
        Pointage pointage = pointageForm.get();
		        
        return pointageRepository.insert(pointage).thenApplyAsync(data -> {
            return GO_HOME;
        }, httpExecutionContext.current());

}

PointageController.java ( import data from EXCEL file )

    public CompletionStage<Result> importer() throws IOException, InvalidFormatException {       	  
        		

			
		final String SAMPLE_XLSX_FILE_PATH = "./public/test.xls";
	    Workbook workbook = WorkbookFactory.create(new File(SAMPLE_XLSX_FILE_PATH));
        Sheet sheet = workbook.getSheetAt(0);
        DataFormatter dataFormatter = new DataFormatter();
		
        
		Row row;
        for (int i = 0; i <= sheet.getLastRowNum(); i++) 
		{
            row = (Row) sheet.getRow(i);
     
		    Pointage pointage = new Pointage();
		    Utilisateur user = new Utilisateur();
		
		    pointage.pointagedate = row.getCell(0).getDateCellValue();
		    
			pointage.utilisateur = user.find.byId( Long.valueOf( dataFormatter.formatCellValue(row.getCell(1)) ) );

            ebeanServer.insert(pointage);

    
 	     }	

	     
		 
		 workbook.close();
		 
		
	        return supplyAsync(() -> {
            flash("success", "File Pointage importé avec succès");
            return GO_HOME;
            }, httpExecutionContext.current());
	
	}