I am trying to recreate this old NetBeans hibernate-webapp tutorial. All the project does is retrieve data from a MySQL database using JSF managed beans.
I'm having the following problem, which I assume is because I'm using newer software versions, but I would like to know what adjustments are needed for the project to work using more recent versions:
I am able to show the initial 10 rows of retrieved data, which is the data that is displayed in the browser when 'run' is executed from NetBeans. However, when I click on a link in the rendered web page to display the next 10 results I receive an empty table (there is no error message, the column titles are there but there's no rows of data, only one row of empty cells is rendered.)
I've altered the tutorial to use StandardServiceRegistryBuilder, as explained here. Also, I'm using @Named(value="filmController") rather than @MessageBean in FilmController.java.
- My setup is:
- Hibernate 4.3
- NetBeans 8.1
- Glassfish 4.1.1
- mysql-connector-java-5.1.39-bin.jar
- JSF 2.2
- JDK 1.8.0_92
I have tried using WildFly instead of GlassFish but I get exactly the same problem.
The fact that the 1st page renders correctly suggests that there is no syntax error.
The problem seems to be how I try to retrieve the data from within the browser. In FilmHelper.java I've many methods that retrieve data in the following manner:
List<Actor> actorList = null;
try {
org.hibernate.Transaction tx = session.beginTransaction();
Query q = session.createQuery (...some tested query);
actorList = (List<Actor>) q.list();
} catch (Exception e) {
e.printStackTrace();
}
(But as I say, these methods work fine when the project first initialises. )
In summary: I wish to know why the data is correctly loaded from MySQL when the web page is first initialised, but do not retrieve and/or show any more data from the database when hyperlinks are subsequently clicked.