openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pinaki Poddar" <>
Subject RE: Equivalent class in OpenJPA.
Date Fri, 03 Aug 2007 14:46:52 GMT
 Try using named/positional parameters in JPQL.
 Query query = session.createQuery("select model from GeneralConfigDTO
model where = ?cname");
 query.setParameter("cname", configName);


 Query query = session.createQuery("select model from GeneralConfigDTO
model where = :1"); // index starts from 1
 query.setParameter(1, configName);

 If the query being executed multiple times, binding parameters will
save repeated query compilation.
2. It may be useful to post the exact SQL being used by Hibernate &

Pinaki Poddar

-----Original Message-----
From: Sreedhar.sirigiri [] 
Sent: Friday, August 03, 2007 8:22 AM
Subject: Equivalent class in OpenJPA.

Hi All,

We are porting our application from Hibernate to OpenJPA in the Database
tier. We faced performance problems while processing the JPQL queries.

here are the sample code snippets:


//do something

Criteria criteria = session.createCriteria(GeneralConfigDTO.class);
criteria.add(Expression.eq("name", configName)); GeneralConfigDTO
configDTO = (GeneralConfigDTO)criteria.uniqueResult();

//do something

//do something

Query query = session.createQuery("select model from GeneralConfigDTO
model where = '"+configName+"'"); try{
  GeneralConfigDTO configDTO =
}catch(NoResultException nre){
  configDTO = null;
}catch(NonUniqueResultException ure){
  configDTO = null;

//do something

We have around 21 tuples in the relation "GeneralConfigDTO".

The Hibernate code snippet is getting executed in around 20msecs,
whereas, OpenJPA code snippet is taking around 400msecs, which is
accounting for overall performance of the Application.

The reason why we went for JPQL is because, we didn't find an equivalent
Hibernate's "Criteria" class in OpenJPA. 

Is there any configurations that we have to do to optimize JPQL queries.

Is there any equivalent class for "Criteria" in OpenJPA.

Any help would be highly appreciated.

Thanks in advance.

Sreedhar Sirigiri.

View this message in context:
Sent from the OpenJPA Developers mailing list archive at

Notice:  This email message, together with any attachments, may contain information  of  BEA
Systems,  Inc.,  its subsidiaries  and  affiliated entities,  that may be confidential,  proprietary,
 copyrighted  and/or legally privileged, and is intended solely for the use of the individual
or entity named in this message. If you are not the intended recipient, and have received
this message in error, please immediately return this by email and then delete it.

View raw message