Reputation: 1575
I'm using eclipse persistence jpa with OracleDriver and I can't get why it shows some extra queries in logs. Example:
Query q = em.createQuery("SELECT v FROM Vehicle v")
.setFirstResult(0)
.setMaxResults(1);
List<Vehicle> list = q.getResultList();
What I see in eclipselink logs is:
Execute query ReadAllQuery(referenceClass=Vehicle sql="SELECT ID, ... FROM VEHICLE")
[EL Fine]: 2012-05-18 11:03:28.076--ServerSession(763807850)--Connection(340360448)--Thread(Thread[main,5,main])
--SELECT * FROM (SELECT /*+ FIRST_ROWS */ a.*, ROWNUM rnum FROM (SELECT ID AS a1, .... FROM VEHICLE) a WHERE ROWNUM <= ?) WHERE rnum > ?
bind => [1, 0]
So, the first query really scares me. Does it really queries all the records from the table, even if I use setMaxResults?
Upvotes: 1
Views: 2961
Reputation: 16273
No, it doesn't read all the records. The query sent to the db connector is the second one.
Upvotes: 1