Session/EntityManager is closed and Unexpected access to the database

Would like to seek your advice regarding on my issue.

So I have an angular front end which is calling my some backend api. One of which is my api that fetches list of person. at first i dont get any issues.. but when i refresh my angular page in the browser by hitting F5. I’m getting this error.

This also the same using postman.

Caused by: java.lang.IllegalStateException: Session/EntityManager is closed 2020-07-13 03:33:54,324 ERROR [org.hib.AssertionFailure] (executor-thread-1) HHH000099: an assertion failure occurred (this may indicate a bug in Hibernate, but is more likely due to unsafe use of the session): org.hibernate.AssertionFailure: Unexpected access to the database 2020-07-13 03:33:54,331 ERROR [org.jbo.res.res.i18n] (executor-thread-1) RESTEASY002020: Unhandled asynchronous exception, sending back 500: org.hibernate.AssertionFailure: Unexpected access to the database

public Uni<List<Person>> getAll(){         return this.mutinySession                 .flatMap(session -> session.createNamedQuery("Person.findAll",Person.class)                         .getResultList())                 .onFailure().invoke(ex-> new PersonException(ex.getMessage(), ALL_FETCH)); }  public Uni<Person[]> getAll(String sort, String order, Long pageNumber,Integer size){         return this.mutinySession                 .flatMap(session -> {                     var sql = "SELECT * " +                             "FROM PERSON ORDER by :sort " + order + " " +                             "OFFSET ( :size * ( (:pageNumber) - 1)) ROWS " +                             "FETCH NEXT :size ROWS ONLY";                     return session.createNativeQuery(sql,Person.class)                             .setParameter("sort",sort)                             .setParameter("pageNumber",pageNumber + 1)                             .setParameter("size",size)                             .getResultList();                 })                 .map(persons -> persons.toArray(new Person[persons.size()]))                 .onFailure().invoke(ex-> new PersonException(ex.getMessage(),ALL_FETCH));  } 
Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.