0

I have made a DAO method to access the DB and get the results based on STATUS=TECHERROR. The sample code is as -

public void loadTable() {
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<MyDTO> criteriaQuery = criteriaBuilder.createQuery(MyDTO.class);
Root<MyDTO> dashBoard = criteriaQuery.from(MyDTO.class);

ParameterExpression<String> p = criteriaBuilder.parameter(String.class);
criteriaQuery.select(dashBoard).where(criteriaBuilder.equal(dashBoard.get("status"), p));

TypedQuery<MyDTO> query = entityManager.createQuery(criteriaQuery);
query.setParameter(p, "TECHERR");

List<MyDTO> MyDtoList = query.getResultList();}

This is working perfectly fine. Now I want only 200 rows/records to be fetched.

I tried solutions provided at this stackoverflow link

but it is not working. Snippet of the error is -

Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:82) at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49) at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)

Please help me find a way to achieve this functionality.

Community
  • 1
  • 1
ankit rai
  • 324
  • 2
  • 7
  • 16

0 Answers0