| Author |
Need help
|
Jasmine kaur
Ranch Hand
Joined: Nov 25, 2003
Posts: 157
|
|
Hi All,
In our project we have used EJB3.0 and JPA and while working on this we need to see the sql queries formed by JPA
which can help us what joins are getting establish and locks so that we can improve our query, so I need to know
how to see the sql query formed by JPA at run time .
These are the queries
@NamedQuery(name = DetectionEvent.RETRIEVE_DE_LIST_FOR_REPROCESSING, query = "SELECT DISTINCT de "
+ " FROM DetectionEvent de " + "WHERE de.reprocessDE = '" + LrucConstants.DB_YES
+ "' ORDER BY de.chargePointId, de.captureDatetime ASC"),
and this is a method
public List<SummaryRecord> getSRsRequiringRejection(Timestamp pStartTime, Timestamp pEndTime)
{
logger.trace("Entry:getSRsRequiringRejection");
// UC-CORE-ASS002 Reject Detection event
// This retrieves a list of SummaryRecord entities from the
// SUMMARYRECORD
// table in the EventAndVURDAO where the ‘requiresRejection’ flag is
// set.
Query query = mEntityManager.createNamedQuery(SummaryRecord.RETRIEVE_SUMMARY_RECORD_LISTS);
query.setParameter(SummaryRecord.PARAM_START_TIME, pStartTime);
query.setParameter(SummaryRecord.PARAM_END_TIME, pEndTime);
List<SummaryRecord> summaryRecord = query.getResultList();
return summaryRecord;
}
Need to see complete query which is getting generated at runtime so that I can see locks and joins on the table so that w ecan make improvements ..
Please tell us how to acheive this in JPA.
Thanks in advance.
|
jasmine kaur
|
 |
Vinod Tiwari
Ranch Hand
Joined: Feb 06, 2008
Posts: 458
|
|
You can use below property for SQL queries:
|
Vinod Tiwari | Twitter
|
 |
Jasmine kaur
Ranch Hand
Joined: Nov 25, 2003
Posts: 157
|
|
Hi Vinod ,
Thanks and If Im correct I need to put this in persistence.xml file and this seeting will help me to print the query which is created at runtime by JPA.
Please correct me ifIm wrong.
Thanks alot
|
 |
Singh Harmeet
Ranch Hand
Joined: Aug 05, 2011
Posts: 114
|
|
i m not sure about EJB with JPA but in hibernate we need to enabel the show queries in hibernate.cfg.xml file like :-
|
With Regards :-
Harmeet Singh
|
 |
 |
|
|
subject: Need help
|
|
|