By default in JPA a flush() is triggered before any query execution. This is done to ensure the database reflects any changes made so it return the correct query results.
flush has to determine if any managed objects changed, and then write these changes to the database, so depending on how many managed objects and changes, this can take a while.
Normally a flush is not required, and sometimes even not desired, so it is best to turn it off using the EntityManager or Query setFlushMode() API.
See,
http://en.wikibooks.org/wiki/Java_Persistence/Querying#Flush_Mode
In EclipseLink you can disable the auto flush entirely using the persistence
unit property,
"eclipselink.persistence-context.flush-mode"="COMMIT"