Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. public List<A> daoMethod() {
  2. List<Object[]> dbResult = getDbResults();
  3. List<A> javaObjects = new ArrayList<>();
  4.  
  5. // build nested Java objects
  6. for (Object[] line in dbResult) {
  7. A a = new A();
  8. a.setProp1(line[0]);
  9. a.setProp2(line[1]);
  10. // and so on...
  11. javaObjects.add(a);
  12. return javaObjects ;
  13. }
  14. }
  15.  
  16. public ResponseEntity<A> controllerMethod() {
  17. List<A> javaObjects = myDao.daoMethod();
  18. return new ResponseEntity(javaObjects, HttpStatus.OK);
  19. }
  20.  
  21. @JsonInclude(JsonInclude.Include.NON_NULL) // removes all fields having NULL value
  22. public abstract class BaseDto implements Serializable{
  23. // some properties...
  24. }
  25.  
  26. {
  27. prop1: "some string",
  28. prop2: [{},{},{}],
  29. prop3: [],
  30. prop4: {},
  31. }
  32.  
  33. {
  34. prop1: "some string"
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement