Hi i have big problem getResultList in while loop get slower every next iteration, code:
Code:
Query q = sc.getEntityManager().createQuery("select i from InvoiceEJB i join fetch i.customer");
final Integer MAX_RESULT = 500;
q.setMaxResults(MAX_RESULT);
q.setFirstResult(0);
List<InvoiceEJB> invList = new ArrayList<InvoiceEJB>();
boolean hasElement = true;
Integer index = 0;
while (hasElement){
log.info(index);
List<InvoiceEJB> tmpList = q.getResultList();
invList.addAll(tmpList);
if (tmpList.size()<MAX_RESULT ){
hasElement=false;
break;
}
q.setFirstResult(index+=MAX_RESULT);
}
Whay is hibernate slowing down?
Im using hibernate 3 and mysql 5 and jboss4.0.3 in mysql cache is disabled.
my persistence.xml is realy simple
Code:
<?xml version="1.0" encoding="UTF-8"?>
<persistence>
<persistence-unit name="AppManager">
<jta-data-source>java:/AppDS</jta-data-source>
<properties>
<property name="hibernate.dialect"
value="org.hibernate.dialect.MySQLInnoDBDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
</properties>
</persistence-unit>
</persistence>
AppDS source:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>AppDS</jndi-name>
<connection-url>jdbc:mysql://localhost:3306/standard?characterEncoding=utf8&autoReconnect=true</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>root</user-name>
<password>password</password>
<max-pool-size>50</max-pool-size>
<transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
</local-tx-datasource>
</datasources>
any idea?;/