1

I have a JAX-RS method that returns me a List with DO's. Unfortunetly when I go to the path which is mapped by the method i get only an empty json list like:

[{}, {}, {}]

My resource method looks like this:

@GET
@Produces("application/json")
public List<ModelDO> getModels() {
    List<ModelDo> models = modelRepo.findAllModelsWithName("Name");
    return models;
} 

I'm 100% sure the objects exists and the list isn't empty, because I have checked it in the debugger.

The ModelDO class is a simple POJO:

public class ModelDO {
    private int id;
    private String name;

    //public getters
}

What should I do to get an non empty json response? PS. When I'm returning a single object I get the same problem -> {}

EDIT:

modelRepo:

public List<ModelDO> findAllModelsWithName(String name){
    return new JPAQueryFactory(entityManager).selectFrom(modelEntity)
                                       .where(modelEntity.name.eq(name))
                                       .fetch();
}

ModelRepo.class is @Injected into my Resoure class

0

1 Answer 1

1

The reason was that my Model object did not have field setters, only getters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.