'Generate inner JSON object in JHipster

I have this SQL code generated by JHipster which I need to modify:

RowsFetchSpec<Employees> createQuery(Pageable pageable, Criteria criteria) {
        List<Expression> columns = EmployeesSqlHelper.getColumns(entityTable, EntityManager.ENTITY_ALIAS);
        columns.addAll(AccountsSqlHelper.getColumns(accountTable, "account"));
        columns.addAll(RolesSqlHelper.getColumns(roleTable, "role"));
        SelectFromAndJoinCondition selectFrom = Select
            .builder()
            .select(columns)
            .from(entityTable)
            .leftOuterJoin(accountTable)
            ......
            .equals(Column.create("id", roleTable));

        String select = entityManager.createSelect(selectFrom, Employees.class, pageable, criteria);
        String alias = entityTable.getReferenceName().getReference();
        String selectWhere = Optional.ofNullable(criteria).map(crit -> select + " " + "WHERE" + " " + alias + "." + crit).orElse(select); // TODO remove once https://github.com/spring-projects/spring-data-jdbc/issues/907 will be fixed

        return db.sql(selectWhere).map(this::process);
    }

    private Employees process(Row row, RowMetadata metadata) {
        Employees entity = employeesMapper.apply(row, "e");
        entity.setAccount(accountsMapper.apply(row, "account"));
        entity.setRole(rolesMapper.apply(row, "role"));
        return entity;
    }

As you can see the second Java method populates inner JSON code block.

I need to replace this code with this SQL code:

   @Query("SELECT * " +
        " FROM employees e " +
        ..........
        "LIMIT :limit " +
        "OFFSET :offset")
    Flux<Employees> findAllByInstAccountParam(@Param("params") String params, @Param("limit") long limit, @Param("offset") long offset);

How I apply the Java method process after executing the SQL query for findAllByInstAccountParam?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source