Returning a collection of view models would work:

@ViewModel // or @DomainObject(nature = Nature.VIEW_MODEL)
public class UserCount {

    public UserCount(final LocalDate date, final BigInteger count) {
        this.date = date;
        this.count = count;
    }

   @Getter @Setter // Uses Lombok to generate getter and setters
   private LocalDate date;

   @Getter @Setter
   private BigInteger count;
}

HTH

On 17 November 2016 at 17:32, Aída Betzabeth Dávila Sotelo <
aida.dav...@vortech-it.com> wrote:

> Hi!
>
> I have the following issue. I need to do a count of registered users per
> day in my application.
> I have the correct query, but I cannot display the results on screen.
>
> I tried with different types of data, at the end I put a simple list of
> string but sends me the following error, instead of information:
>
> ??? EntityModel objectAdapter oid: null
>
> Could you recommend me another way that I can solve
> this problem? or how could I get the count of some object by date?.
>
> Thanks in advance.
> Aida Davila
>
> This is my code:
>
>
>
> public List<String> FindNewUsersCountPerDay() {
>
>     System.out.println("Find");
>     List <User> MyUsers = this.findAllUsers();
>
>     List<String> lista = new ArrayList<String>();
>
>     Map<String, Long> countByDate  = MyUsers.stream()
>             .collect(Collectors
>                             .groupingBy(User::getCreationDate,
> Collectors.counting())
>                      );
>
>     Set<Map.Entry<String, Long>> set = countByDate.entrySet();
>     List<Map.Entry<String, Long>> userList = new ArrayList<>(set);
>     Iterator<Map.Entry<String, Long>> it = userList.iterator();
>
>     int index = 0;
>
>     while (it.hasNext()) {
>         Map.Entry<String, Long> entry = it.next();
>         String result = index + " " + entry.getKey() + " " +
> entry.getValue();
>         lista.add(result);
>         System.out.println("Entry from converted list : " + index + " 1:"
> +  entry.getKey() + " 2:" + entry.getValue());
>         index++;
>     }
>
>     System.out.println(countByDate);
>
>     return (lista);
> }
>
>
  • Count Aída Betzabeth Dávila Sotelo
    • Re: Count Jeroen van der Wal

Reply via email to