samedi 25 janvier 2020

Spring boot Design Patterns and SSR vs REST api got a few questions

i would like to ask a few questions about building spring boot 2 applications.So few months ago i decided to start building basic blog app with spring boot and angular, I've made a few entities, rest controllers for users, roles, articles, categories and comments, made a service and service implementation for each, for example my UserServiceImpl looked like this using HQL, not repositories.

@Override
    public List<User> getUsers() {
        Query q = entityManager.createQuery("select u from User u");
        List<User> users = q.getResultList();

        if(users == null){
            users = new ArrayList<>();
        }

        return users;
    }

Is this the right way to do it? Do i have to build it like that ,because I didn't used any repo's and every spring-boot-best-practices project I saw was using repositories instead of HQL and I'm not really sure should i use repositories or custom services with HQL. I am totally lost with that.This is my first question.

The second question is should I use server side rendering and api or i should use only api without server side rendering, because i saw a few projects made with ssr and rest api's which confused me a lot.

Thanks for the help provided

Aucun commentaire:

Enregistrer un commentaire