Hi , i just built an application with Hibernate, which use an MySql database.
I have a snippet of code like below :
Code:
List<FitArticle> articleList = new ArrayList<>();
PerformanceTest.setStarttime();
articleList = db.getArticleByFilter(Filter.STANDARD);
PerformanceTest.printTime("Getting Articles");
PerformanceTest.setStarttime();
List<FitArticle> articleNewList = new ArrayList<>();
articleNewList.add(articleList.get(0));
System.out.println(articleList.size());
controller.renderPage(articleList, page, firstCall);
PerformanceTest.printTime("Rendering");
By Using PerformanceTest which just mesures the time between, i got a result that Fetching a list of objects (300 items) take only 200ms or something like that. But working with these new fetched objects take way way longer than it used to be with JDBC.
For clarity, by working with objects i meant render the objects to a html web view.
Further more, i tried to troubleshooting the problem, by using YourKit Java Profiler to figure out exactly which Methods took so long and on top of the table is (which with distance longer than any other methods):
Quote:
java.lang.ClassLoader.loadClass(String)
EDIT : This may not be relevant, but i will post it anyway: This took also very long.
Quote:
org.hibernate.internal.SessionImpl.initializeCollection(PersistentCollection, boolean)
Does anyone have some idea why ?
The Methode i used to fetch objects :
Quote:
List<FitArticle> list = new ArrayList<FitArticle>();
Session session = factory.openSession();
Transaction tx = null;
Criteria crit = session.createCriteria(FitArticle.class);
// Here some lines to modify Criteria.
list= crit.list();
return list;
Thanks in advance!