Discussions

Performance and scalability: Migrated from Hibernate to JPA 1.2.2 - performance issues

  1. Migrated from Hibernate to JPA 1.2.2 - performance issues (2 messages)

    we recently migrated from hibernate to EJB3/JPA. Currently seeing the performance issues a lot. are there any tuning helps on JPA that we can look at? we are already using the query caching one...one interesting thing that we found is, the number of calls between the application server and the DB server increased a lot after migrating to JPA, for a single user test for the screen flow of 20 screens, it is generating almost 4000 calls between the appserver and db server, we know that we for sure dont have those many SQLs written, but dont have a clue as to what must be happening..

     

    Any help is appreciated..

  2. Hi,

    I have a strong feeling that you have lazy initialization set to false in JPA. Else you have missed this property in many-to-one mappings of JPA. Look at bold text.

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = "column_name")

     

    It is needed in JPA. In hibernate default fetch mode is lazy=true, but for JPA for many-to-one mappings, the case is different.

    Asiri

  3. HI Asiri,

     

    Thanks for the response, one of the sample of our code is like below - 

     

    @ManyToOne

     @JoinColumns({ @JoinColumn(name="ref_group_cd", referencedColumnName="ref_group_cd"), @JoinColumn(name="product_cd", referencedColumnName="product_cd"), @JoinColumn(name="sten_clause_no", referencedColumnName="sten_clause_no"), @JoinColumn(name="product_eff_date", referencedColumnName="product_eff_date"), @JoinColumn(name="section_cd", referencedColumnName="section_cd"), @JoinColumn(name="risk_cd", referencedColumnName="risk_cd"), @JoinColumn(name="coverage_cd", referencedColumnName="coverage_cd") })

     

    should we just change it to below??

     

    @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)

     @JoinColumns({ @JoinColumn(name="ref_group_cd", referencedColumnName="ref_group_cd"), @JoinColumn(name="product_cd", referencedColumnName="product_cd"), @JoinColumn(name="sten_clause_no", referencedColumnName="sten_clause_no"), @JoinColumn(name="product_eff_date", referencedColumnName="product_eff_date"), @JoinColumn(name="section_cd", referencedColumnName="section_cd"), @JoinColumn(name="risk_cd", referencedColumnName="risk_cd"), @JoinColumn(name="coverage_cd", referencedColumnName="coverage_cd") })