background preloader

Développement

Facebook Twitter

Java

Les Cast Codeurs Podcast | Liste des épisodes. Expert Cheat Sheets & Tutorial Guides for Developers | Refcardz. Fresh links for developers. Eyal Lupu Java Blog >> Hibernate - Tuning queries Using Paging, Batch Size, and Fetch Joins. Hibernate - Tuning queries Using Paging, Batch Size, and Fetch Joins Hi, Another entry about queries - this time a tuning test case and the relations between simple queries, join fetch queries, paging query results, and batch size. Paging the Query Results Since I have never said anything about paging in this blog I start with a short introduction about paging in EJB3: To support paging the EJB3 Query interface defines the following two methods: setMaxResults - sets the number of maximum rows to retrieve from the databasesetFirstResult - sets the first row to retrieve For example if our GUI displays a list of customers and we have 500,000 customers (database rows) in out database we wouldn't like to display all 500,000 records is one view (even if we put performance considerations aside - nobody can do anything with a list of 500,000 rows).

Here is a sample use, for fetching the first tow pages of 100 rows each: Test Case Description Tuning Requirement #1 - Fetch Customers and Their Orders. Eyal Lupu Java Blog. HIBERNATE - Persistence Relationnelle dans un Java standard. Hibernate. Yesterday a collegue of mine asked if I could build some functionality to physically delete records in our database. Since deleting things is always a good idea, I immediately started to work on his request.

As we are using an ORM (Hibernate) to manage our relational persistence, this would just be a matter of adding a single line of code: And all the Hibernate magic combined with some cascading would take care of the deletion. So I concluded my assignment fast, and got the well know warm cosy feeling: 'job wel done'. However, suddenly I realised that the combinaton: "hibernate, magic, job well done, warm cosy feeling" has put me into problems before. In fact, I remeber this since last time I was in that position I ended up feeling exactly like this man did. Just to be sure I went back to the code and configured my logging to print out what Hibernate was doing. The problem is that each child is deleted one by one. 31398 [main] DEBUG org.hibernate.SQL - delete from product where id=? 1. Le Touilleur Express. OpenClassrooms, Le Site du Zéro - Les cours les plus ouverts du Web.