Announcement Announcement Module
Collapse
No announcement yet.
[ROO 1.2.0]Hibernate performance with finders loading each entity with a select Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • [ROO 1.2.0]Hibernate performance with finders loading each entity with a select

    Hi all,

    I'm new to spring roo and I'm enjoying it since a few days. But I have an performance issue with hibernate loading entities.

    I have created a project and add hibernate / database reverse / web mvc.

    My tables have a lot of rows inside.

    When my entityManager is performing a select * from a table, it seems that each entities are loaded with a select ...

    For example my method is :

    Code:
    public static List<com.edhec.usrmgt.model.ComArtificialPerson> findAllComArtificialpeople() {
            return entityManager().createQuery("SELECT o FROM ComArtificialPerson o", ComArtificialPerson.class).getResultList();
        }
    Nothing complex, but this little query is giving me perhaps 2minutes to complish has it seems that each row is loaded in a separate select ...

    Here is a piece of the log generated :

    Code:
    2012-01-06 16:15:33,022 [http-8080-3] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
    2012-01-06 16:15:33,046 [http-8080-3] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - HQL: SELECT o FROM com.edhec.usrmgt.model.ComArtificialPerson o
    2012-01-06 16:15:33,046 [http-8080-3] DEBUG org.hibernate.hql.ast.QueryTranslatorImpl - SQL: select comartific0_.CNT_ID as CNT1_3_, comartific0_.COMPANY_NAME as COMPANY2_3_, comartific0_.CREATED_BY as CREATED3_3_, comartific0_.CRT_CKA_ID_NAF_CODE as CRT4_3_, comartific0_.CRT_CKA_ID_NATIONALITY as CRT5_3_, comartific0_.CRT_ID_NAF_CODE as CRT6_3_, comartific0_.CRT_ID_NATIONALITY as CRT7_3_, comartific0_.DATE_CREATED as DATE8_3_, comartific0_.DATE_MODIFIED as DATE9_3_, comartific0_.KAP_ID as KAP10_3_, comartific0_.MODIFIED_BY as MODIFIED11_3_ from COMMON.COM_ARTIFICIAL_PERSON comartific0_
    2012-01-06 16:15:33,047 [http-8080-3] DEBUG org.hibernate.hql.ast.ErrorCounter - throwQueryException() : no errors
    2012-01-06 16:15:33,109 [http-8080-3] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
    2012-01-06 16:15:33,109 [http-8080-3] DEBUG org.hibernate.jdbc.ConnectionManager - opening JDBC connection
    2012-01-06 16:15:33,131 [http-8080-3] DEBUG org.hibernate.SQL - select comartific0_.CNT_ID as CNT1_3_, comartific0_.COMPANY_NAME as COMPANY2_3_, comartific0_.CREATED_BY as CREATED3_3_, comartific0_.CRT_CKA_ID_NAF_CODE as CRT4_3_, comartific0_.CRT_CKA_ID_NATIONALITY as CRT5_3_, comartific0_.CRT_ID_NAF_CODE as CRT6_3_, comartific0_.CRT_ID_NATIONALITY as CRT7_3_, comartific0_.DATE_CREATED as DATE8_3_, comartific0_.DATE_MODIFIED as DATE9_3_, comartific0_.KAP_ID as KAP10_3_, comartific0_.MODIFIED_BY as MODIFIED11_3_ from COMMON.COM_ARTIFICIAL_PERSON comartific0_
    2012-01-06 16:15:33,393 [http-8080-3] DEBUG org.hibernate.jdbc.AbstractBatcher - about to open ResultSet (open ResultSets: 0, globally: 0)
    2012-01-06 16:15:33,406 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000893]
    2012-01-06 16:15:33,406 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,414 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,433 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000894]
    2012-01-06 16:15:33,433 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,441 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,442 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000895]
    2012-01-06 16:15:33,442 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,452 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,454 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000896]
    2012-01-06 16:15:33,455 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,464 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,465 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000897]
    2012-01-06 16:15:33,465 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,473 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,474 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000898]
    2012-01-06 16:15:33,475 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,482 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,485 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000899]
    2012-01-06 16:15:33,486 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,493 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,494 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000900]
    2012-01-06 16:15:33,495 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,503 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,504 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000901]
    2012-01-06 16:15:33,505 [http-8080-3] DEBUG org.springframework.beans.factory.annotation.InjectionMetadata - Processing injected method of bean 'com.edhec.usrmgt.model.ComArtificialPerson': PersistenceElement for transient javax.persistence.EntityManager com.edhec.usrmgt.model.ComArtificialPerson.entityManager
    2012-01-06 16:15:33,513 [http-8080-3] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'entityManagerFactory'
    2012-01-06 16:15:33,514 [http-8080-3] DEBUG org.hibernate.loader.Loader - result row: EntityKey[com.edhec.usrmgt.model.ComArtificialPerson#PRODSIL00000000902]
    First this table had an one-to-one relationship with another table, so I spend a day presuming that it was my relationship who made a lazy loading, so I tried a lot of querie with no results. So today I remove this association, my table is juste some column. But still have the problem.

    So I can't imagine using that for a real project, just to load the page takes me 2 minutes.

    Am I missing something ?

    Excuse me for my english if I made some mistakes

    I find that the problem is referenced here : https://jira.springsource.org/browse...s:all-tabpanel

    Thanks
Working...
X