I am trying to get value of total number of raw in my table in spring roo project. This can be done by built-in method of Spring roo's aspectJ file.
The method defined as the below in UserAccount_Roo_Jpa_ActiveRecord.aj
file:
public static long UserAccount.countUserAccounts() {
return entityManager().createQuery("SELECT COUNT(o) FROM UserAccount o", Long.class).getSingleResult();
}
I want to print this long value to my jspx page. How to call this method and from where? Need help. Thnx.
Customize the Controller method that handles the related request:
1: Push-in the controller method you,e.g. show
method
2: Modify that method run the query and place the result available for view layer:
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public String show(@PathVariable("id") Long id, Model uiModel) {
...
Long count = UserAccount.countUserAccounts();
uiModel.addAttribute("countUserAccounts", count);
...
}
3: Modify the jspx as needed.