I try to make a mini forum and I'm stuck. How it should be, first of all you create a post and write message of topic, it redirects to all post and add new posted which you created, an user click on post and it shows in next page all message which filled in. Also I made a comment system, I every post has to have comments, so the problem is in my code which is below, when I tried to make that comments work, it works like this: doesn't matter what post id you choose it shows all comments which does exist, so I changed and failed. May someone explains me, how to make correct with Hibernate.
PostController is: pay attention on method seeMessage, it findes post by id and show message.
package com.pandora.controllers;
import com.pandora.domain.Post;
import com.pandora.services.CommentService;
import com.pandora.services.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller
#RequestMapping("/posts")
public class PostController {
#Autowired
private PostService postService;
#Autowired
private CommentService commentService;
#RequestMapping
public String findAll(Model model) {
model.addAttribute("posts", postService.findAll());
return "post/post";
}
#RequestMapping(value = "/click", method = RequestMethod.GET)
public String click() {
return "post/new";
}
#RequestMapping(value = "/add", method = RequestMethod.POST)
public String addPost(#ModelAttribute Post post) {
postService.addPost(post);
return "redirect:/posts";
}
#RequestMapping(value = "/{title}/find", method = RequestMethod.GET)
public String findByName(#PathVariable String title) {
postService.findByTitle(title);
return "redirect:/posts";
}
#RequestMapping(value = "/{id}/see", method = RequestMethod.GET)
public String seeMessage(#PathVariable long id, Model model) {
Post post = postService.findById(id);
System.out.println("the id is " + id);
System.out.println("the value of comments are " +post.getComments().size());
model.addAttribute("post", post);
// model.addAttribute("postMessage", post.getComments());
return "post/postmessage";
}
#RequestMapping(value = "/{id}/delete")
public String delete(#PathVariable long id) {
postService.delete(id);
return "redirect:/posts";
}
#RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(){
return "login";
}
}
CommentController is: And here pay attention on method addComment, first I find from what id post it went and after this I have to add comment to founded post.
package com.pandora.controllers;
import com.pandora.domain.Comment;
import com.pandora.domain.Post;
import com.pandora.services.CommentService;
import com.pandora.services.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.ArrayList;
import java.util.List;
#Controller
#RequestMapping("/comments")
public class CommentController {
#Autowired
private CommentService commentService;
#Autowired
private PostService postService;
#RequestMapping(value = "/post/{postId}/comment", method = RequestMethod.POST)
public String addComment(#PathVariable long postId, #ModelAttribute Comment comment){
Post post = postService.findById(postId);
System.out.println(post.getId());
System.out.println(comment.getMessage());
List comments = new ArrayList();
comments.add(commentService.addComment(comment));
post.setComments(comments);
return "redirect:/posts";
}
#RequestMapping(value = "/{id}/delete", method = RequestMethod.GET)
public String delete(#PathVariable long id){
commentService.delete(id);
return "redirect:/posts";
}
}
Post entity is:
package com.pandora.domain;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
import java.util.List;
#Entity
#Setter
#Getter
#NoArgsConstructor
public class Post {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
#OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "post")
private List comments;
#Column(length = 10000)
private String message;
private String title;
}
PostService is:
package com.pandora.services;
import com.pandora.domain.Post;
import com.pandora.domain.repositories.PostRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
#Service
public class PostService {
#Autowired
private PostRepository postRepository;
public Post addPost(Post post){
return postRepository.saveAndFlush(post);
}
public List findAll(){
return postRepository.findAll();
}
public Post findByTitle(String title){
return postRepository.findByTitle(title);
}
public Post findById(long id){
return postRepository.findOne(id);
}
public void delete(long id){
postRepository.delete(id);
}
}
Comment entity is:
package com.pandora.domain;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.*;
#Entity
#Setter
#Getter
#NoArgsConstructor
public class Comment {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
#ManyToOne(fetch = FetchType.EAGER)
private Post post;
private String message;
}
and CommentService is :
package com.pandora.services;
import com.pandora.domain.Comment;
import com.pandora.domain.repositories.CommentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
#Service
public class CommentService {
#Autowired
private CommentRepository commentRepository;
public Comment addComment(Comment comment){
return commentRepository.saveAndFlush(comment);
}
public List findAll(){
return commentRepository.findAll();
}
public void delete(long id){
commentRepository.delete(id);
}
public Comment findOne(long id){
return commentRepository.findOne(id);
}
}
and html which showes post which choose by id is: here pay attention to th:each div container. I retrieve from list which are gone from PostController comments. But it doesnt work because when I do it it's always empty. I don't know why it's empty.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
layout:decorator="layout">
<div layout:fragment="content">
<h2 align="center">
<h2 align="left">
<div th:text="${post.title}"></div>
</h2>
</h2>
<h4 align="center">
<div th:text="${post.message}"></div>
</h4>
<hr/>
<h4>Comments:</h4>
<br/>
<h4>
<div th:each="comments : ${post}">
<label for="username"><div th:inline="text">[[${#httpServletRequest.remoteUser}]]: </div> </label>
<div th:each="comment : ${comments.comments}">
<div id="username" th:text="${comment}"></div>
</div>
</div>
</h4>
<br/>
<form method="post" name="comment_form" id="comment_form" th:action="#{'/comments/post/{id}/comment'(id=${post.id}) }" role="form">
<div class="form-group">
<label for="message">Comment</label>
<textarea rows="5" class="form-control" id="message" name="message"/>
</div>
<button type="submit" id="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</html>
You need to change the controller as well. Think about something like this, you have a post with zero comments now. The user then posts a comment on PostController method say:
#RequestMapping(value = "/post/{postId}/addComment", method = RequestMethod.POST)
public String addPost(#PathVariable("postId")long id, #ModelAttribute Comment comment) {
postService.addComment(id, comment);
return "redirect:/to_whatever";
}
And in your PostService you might want to add the below function:
public Post addComment(long id, Comment comment){
Post post = postRepository.findOne(id);
post.getComments().add(comment);
return postRepository.saveAndFlush(post);
}
Change your UI post call accordingly. Also, this will achieve the retrieval part also. Say you want to get comments for a post, all you need to do is find the post by id (or any other unique identifier) and do post.getComments();
Embeddable will establish a OneToMany kind of relation between post and comment. Refer this for more details.
At the database level, you will have something like this:
POST TABLE
post_id post_name
1 A
2 B
POST_COMMENTS TABLE
post_id message
1 C
1 D
2 E
2 F
Hope this clears the issue.
Based on your scenario this is what I understand: You have a post and some comments associated with it. However, when you are trying to retrieve comments for a particular post, you are seeing all comments (from other posts as well).
Assuming the above, I would suggest you to not treat comments as a separate entity because comments will only be present if there is a post and comments have to be associated to a single post. #Embeddable might help in this.
My recommendation would be to try something like this:
Make Comments as embeddable:
#Embeddable
public class Comment {
private String message;
...
...
//Any other properties you might need to add
}
And in the Post Entity, make the below changes:
#Entity
#Setter
#Getter
#NoArgsConstructor
public class Post {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
#ElementCollection(fetch=FetchType.EAGER)
private List<Comment> comments = new ArrayList<>();
#Column(length = 10000)
private String message;
private String title;
}
After this, you might want to loose the CommentService and CommentRepository as they wont be needed any longer. Let me know if this helps.
Related
I am trying to get my Spring MySQL backend to return a mutli table VIEW (not a single table) thru AXIOS to my REACT front end.
I am testing my Backend with POSTMAN (http://localhost:8080/api/v1/cpysiteassetview)
I get an error messages from SPRING and a long error message from POSTMAN (below).
I am close, but going wrong somewhere and I hope someone more familiar with this can shed some light and explain where I am going wrong.
Here is the VIEW\MODEL\REPOSITORY\CONTROLLER.
...
CREATE
ALGORITHM = UNDEFINED
DEFINER = `root`#`localhost`
SQL SECURITY DEFINER
VIEW `cpysiteasset` AS
SELECT
`cpymaster`.`cpymasterid` AS `cpymasterid`,
`cpymaster`.`cpymastercode` AS `cpymastercode`,
`cpymaster`.`cpymastername` AS `cpymastername`,
`sitemaster`.`sitemasterid` AS `sitemasterid`,
`sitemaster`.`sitemastercode` AS `sitemastercode`,
`sitemaster`.`sitemastername` AS `sitemastername`,
`assets`.`assetsid` AS `assetsid`,
`assets`.`assetsidentifier` AS `assetsidentifier`,
`assets`.`assetsname` AS `assetsname`
FROM
((`cpymaster`
JOIN `sitemaster` ON = `cpymaster`.`cpymasterid`)))
JOIN `assets` ON ((`assets`.`sitemaster_sitemasterid` = `sitemaster`.`sitemasterid`)))
ORDER BY `sitemaster`.`sitemastercode` , `assets`.`assetsidentifier`
//MODEL
package net.javaguides.springboot.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.Immutable;
#Entity
#Immutable
#Table(name = "`cpysiteassetview`")
public class CpySiteAssetView {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private int cpymasterid;
private String cpymastercode;
private String cpymastername;
private int sitemasterid;
private String sitemastercode;
private String sitemastername;
private int assetsid;
private String assetsidentifier;
private String assetsname;
#Column(name = "cpymasterid")
public int getCpymasterid() {
return cpymasterid;
}
#Column(name = "cpymastercode")
public String getCpymastercode() {
return cpymastercode;
}
#Column(name = "cpymastername")
public String getCpymastername() {
return cpymastername;
}
#Column(name = "sitemasterid")
public int getSitemasterid() {
return sitemasterid;
}
#Column(name = "sitemastercode")
public String getSitemastercode() {
return sitemastercode;
}
#Column(name = "sitemastername")
public String getSitemastername() {
return sitemastername;
}
#Column(name = "assetsid")
public int getAssetsid() {
return assetsid;
}
#Column(name = "assetsidentifier")
public String getAssetsidentifier() {
return assetsidentifier;
}
#Column(name = "assetsname")
public String getAssetsname() {
return assetsname;
}
}
//Repository
package net.javaguides.springboot.repository;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import net.javaguides.springboot.model.CpySiteAssetView;
#Repository
public interface CpySiteAssetViewRepository1 extends JpaRepository<CpySiteAssetView, Long>{
public List<CpySiteAssetView> findAll();
}
//Controller
package net.javaguides.springboot.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import net.javaguides.springboot.model.CpySiteAssetView;
import net.javaguides.springboot.repository.CpySiteAssetViewRepository1;
#CrossOrigin(origins = "http://localhost:3000")
#RestController
#RequestMapping("/api/v1/")
public class CpySiteAssetViewController {
#Autowired
private CpySiteAssetViewRepository1 cpySiteAssetViewRepository1;
//get all
#GetMapping("/cpysiteassetview")
public List<CpySiteAssetView> getAllCpySiteAssetView(){
return cpySiteAssetViewRepository1.findAll();
}
}
...
Error Message from Spring:
java.sql.SQLSyntaxErrorException: Unknown column 'cpysiteass0_.id' in 'field list'
Error Message from Postman (first part):
"error": "Internal Server Error",
"trace": "org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet\r\n\tat org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:259)\r\n\tat org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:233)\r\n\tat org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:551)\r\n\tat org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:61)\r\n\tat org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:242)\r\n\tat org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(Per
OK..commented out //private long id;
and now it works !!!!!
i am using keycloak and spring to get the user list in a rest service, however the rest return the html instead of json data.
here is the service.
import org.keycloak.representations.idm.UserRepresentation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
#Service
public class UserServiceImpl implements UserService{
#Autowired
KeycloakInstance keycloakInstance;
public List<UserRepresentation> loadUsers(String realm) {
return keycloakInstance.getInstance()
.realm(realm)
.users()
.list();
}
}
here is the controller.
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import org.keycloak.representations.idm.UserRepresentation;
import java.util.List;
#RestController
#RequestMapping("/api/admin/users")
public class UserController {
#Autowired
private UserService userService;
#GetMapping(value = "", produces="application/json")
public List<UserRepresentation> loadUsers() {
String realm = "abc";
return userService.loadUsers(realm);
}
}
any idea how to fix this?
You would need to add the path to #GetMapping, this should work
#ResponseBody
#GetMapping(value = "/api/admin/users", produces="application/json")
public List<UserRepresentation> loadUsers() {
String realm = "abc";
return userService.loadUsers(realm);
}
or using this way
#GetMapping (value = "/api/admin/users", produces = MediaType.APPLICATION_JSON_VALUE)
As #ConstantinKonstantinidis commented, add to RequestMapping produces JSON to apply to your method (and all methods):
#RequestMapping(value = "/api/admin/users", produces = MediaType.APPLICATION_JSON_VALUE
Supported at the type level as well as at the method level
Another option is to add the path to #GetMapping ,e.g.
#RequestMapping("/api/admin")
public class UserController {
#GetMapping(value = "/users", produces="application/json")
When I'm posting a new entity through Postman everything works fine and I get this as an answer:
{
"id": 3,
"ingredients": [
"Eggs",
"Oil"
]
}
But when I'm trying to get the existing entities in the database, the List< String > ingredients is returned as "null":
[
{
"id": 3,
"ingredients": null
}
]
Here is my model:
package com.petie.weeklyrecipesschedule.model;
import javax.persistence.*;
import java.util.List;
#Entity
public class Recipe {
#Id
#GeneratedValue(strategy = GenerationType.AUTO)
private long id;
private String name;
#Embedded
private List<String> ingredients;
protected Recipe() {}
public Recipe(String name, List<String> ingredients) {
this.name = name;
this.ingredients = ingredients;
}
//Getters and setters
//toString()
}
My Repository
package com.petie.weeklyrecipesschedule.repository;
import com.petie.weeklyrecipesschedule.model.Recipe;
import org.springframework.data.jpa.repository.JpaRepository;
public interface RecipeRepository extends JpaRepository<Recipe, Long> {
}
And my controller
package com.petie.weeklyrecipesschedule.controller;
import com.petie.weeklyrecipesschedule.model.Recipe;
import com.petie.weeklyrecipesschedule.repository.RecipeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
#RestController
#RequestMapping("/recipes")
public class RecipeController {
#Autowired
private RecipeRepository recipeRepository;
public RecipeController(RecipeRepository recipeRepository) {
this.recipeRepository = recipeRepository;
}
#GetMapping("/all")
List<Recipe> getAll() {
return recipeRepository.findAll();
}
#PostMapping("/post")
Recipe newRecipe(#RequestBody Recipe recipe) {
return recipeRepository.save(recipe);
}
}
As far as dependencies go, I'm using Spring Web, Spring Jpa, and H2 database.
You can also use #ElementCollection:
#ElementCollection
#CollectionTable(name = "recipe_ingredients",
joinColumns = #JoinColumn(name = "recipe_id"))
#Column(name = "ingredient_name")
private List<String> ingredients;
The JPA annotation #Embedded is used to embed a type into another entity.
Note: In addition, you don't need to send an id in your post request, it will be created automatically.
I have created a simple Spring REST service (POST, PUT). But when i call this service from postman when value store in null.
Student Pojo Class
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import org.springframework.hateoas.ResourceSupport;
#SuppressWarnings("serial")
#Entity
#Table(schema="fishpool")
public class Student extends ResourceSupport implements Serializable {
#Id #GeneratedValue(strategy=GenerationType.AUTO)
private Long sId;
private String name;
private String email;
public Student() {
}
public Student(Long sId, String name, String email) {
this.sId = sId;
this.name = name;
this.email = email;
}
public Long getsId() {
return sId;
}
public void setsId(Long sId) {
this.sId = sId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
#Override
public String toString() {
return "Student [sId=" + sId + ", name=" + name + ", email=" + email + "]";
}
}
RestController Class
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.example.domain.Student;
import com.example.studentService.StudentSerivce;
#RestController
#RequestMapping(value="/api")
public class StudentController {
#Autowired
private StudentSerivce studentService;
private final static Logger log = LoggerFactory.getLogger(StudentController.class);
public StudentController(final StudentSerivce studentService) {
this.studentService = studentService;
}
#GetMapping("/students")
public List<Student> getAllStudent() {
return studentService.findAllStudent();
}
#GetMapping("/student/{id}")
public Student getStudentById(#PathVariable("id") Long id) {
return studentService.findByStudentId(id);
}
#PostMapping("/createStudent")
public ResponseEntity<Student> createStudent(Student student) {
HttpHeaders headers = new HttpHeaders();
headers.add("Reader", "StudentController");
log.info("Post Create Student : " + student);
return new ResponseEntity<Student>(student, headers, HttpStatus.CREATED);
}
#PutMapping("/updateStudent")
public Student updateStudent(Student student) {
log.info("Put Update Student : " + student);
return studentService.updateStudent(student);
}
#DeleteMapping("/deleteStudent/{id}")
public void deleteStudentById(#PathVariable Long id) {
studentService.deleteByStudentId(id);
}
}
Error.log
2018-07-06 14:31:05.405[0;39m [32m INFO[0;39m [35m20240[0;39m [2m---[0;39m [2m[nio-8080-exec-7][0;39m [36mc.example.controller.StudentController [0;39m [2m:[0;39m Put Update Student : Student [sId=null, name=null, email=null]
[2m2018-07-06 14:31:05.705[0;39m [32mDEBUG[0;39m [35m20240[0;39m [2m---[0;39m [2m[nio-8080-exec-7][0;39m [36morg.hibernate.SQL [0;39m [2m:[0;39m insert into student (email, name) values (?, ?)
Hibernate: insert into student (email, name) values (?, ?)
[2m2018-07-06 14:31:44.984[0;39m [32m INFO[0;39m [35m20240[0;39m [2m---[0;39m [2m[nio-8080-exec-8][0;39m [36mc.example.controller.StudentController [0;39m [2m:[0;39m Post Create Student : Student [sId=null, name=null, email=null]
I have no idea where is my mistake, please find the my mistake and suggest me. Please help me. I totally Confused where is my mistake.
Add #RequestBody annotation before Student student like below.
public ResponseEntity<Student> createStudent(#RequestBody Student student)
mark the fields with #JsonProperty like this
#JsonProperty String sId;
#JsonProperty String name;
etc.
I am facing the same problem. the reason why I got the null value because of bad JSON request.
I make a mistake:
{
"name": "111",
"id":"11""
}
after delete the suplus semicolon, the problem fixed.
As Alien pointed out there should be a #RequestBody annotation attached to the model parameter of the post method.
#PostMapping("/createStudent")
public ResponseEntity<Student> createStudent(#RequestBody Student student) {
HttpHeaders headers = new HttpHeaders();
headers.add("Reader", "StudentController");
log.info("Post Create Student : " + student);
return new ResponseEntity<Student>(student, headers, HttpStatus.CREATED);
}
Also, I would suggest that you remove the
#SuppressWarnings("serial") & #Table(schema="fishpool")
Annotations as only the #Entity Annotation is needed with (with the getters and setters of the Model)
I'm trying to use the primefaces LazyDataModel for a tabelaric view in JSF, the problem is that I'm unable to inject anything into the class. I always get null fot the injected object.
For example I'm injecting
#PersistenceContext(unitName = "domainDS")
private EntityManager em;
or an EJB
#EJB
OrganizationHandler orgHandler;
but I get null for both of them.
The whole lazy datamodel class
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.primefaces.model.LazyDataModel;
import org.primefaces.model.SortOrder;
import si.arctur.controller.OrganizationHandler;
import si.arctur.model.Organization;
#Named
#Stateless
public class LazyOrganizationDataModel extends LazyDataModel<Organization> implements Serializable {
private static final long serialVersionUID = 675394666656356734L;
#PersistenceContext(unitName = "domainDS")
private EntityManager em;
#EJB
OrganizationHandler orgHandler;
public LazyOrganizationDataModel() {
super();
}
#SuppressWarnings("unchecked")
#Override
public List<Organization> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String,String> filters) {
List<Organization> data = orgHandler.selectOrganizatoins(first, pageSize, sortField, "asc", filters);
//row count
this.setRowCount(data.size());
return data;
}
}
You're probably not injecting the lazy data model. Based on their examples, they show someone instantiating it. You should instead get a reference via CDI to the bean.