Results 1 to 3 of 3

Thread: Hibernate Performance

  1. #1
    Join Date
    Apr 2007
    Posts
    22

    Default Hibernate Performance

    Hi,

    Here is a scenario while integrating the Hibernate and its performance

    1. I have 8 tables one Master table and 7 child tables. I generated a hbm file that contains link to all the tables as per the database.
    2. hbm file is created using the tool in the eclipse
    3. POJO objects are created basing on the database design. Master POJO and in that we have objects of all the other 7 tables
    4. I do have 8 select queries that execute on above 8 table. In which
    Query 1 – Will retrieve information from table 1 & table 2
    Query 2 – Will retrieve information from table 1, table 2 and table 3
    Query 3 – Will retrieve information from table 1, table 3 and table 4
    Query 4 – Will retrieve information from table 1, table 4 and table 5
    Query 5 – Will retrieve information from table 1, table 2, table 3 and table 4
    Query 6 – Will retrieve information from table 1, table 2, table 3, table 4, table 5, table 6, table 7, table 8
    Query 7 – Will retrieve information from table 1, table 2, table 6, table 7, table 8
    Query 8 – Will retrieve information from table 1, table 7, table 8


    Now the question is because by Master POJO contains links to all the object does hibernate loads all the objects in the memory irrespective of the query.

    For example Query 1 is executed – In this I am trying to retrieve the values for two tables, but my Master POJO and its hbm file contains link to all the tables. So does that mean it will load the content for the rest of the tables even though I am not querying it in the same query.

    If so what would be the best approach for all the above queries that to be followed in the hibernate.


    Thanks
    Badri

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    Default answer 'it depends'. It all depends on your mapping file. How did you specify your relations, lazy, non lazy, join, sub-select etc. If you defined everything non-lazy then yes everything will be retrieved. But as I said it all depends on your mapping file and how you specified your query...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2006
    Location
    Now Germany, previously Ukraine
    Posts
    1,546

    Default

    Yes, it depends, but small ramifications - if nothing concerning fetching strategy was specified, then lazy behavior takes place.

    Quote Originally Posted by mdeinum View Post
    Default answer 'it depends'. It all depends on your mapping file. How did you specify your relations, lazy, non lazy, join, sub-select etc. If you defined everything non-lazy then yes everything will be retrieved. But as I said it all depends on your mapping file and how you specified your query...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •