Reputation: 75
Spring data queries defined as methods on repository interfaces are compiled on application start up. If spring data works in combination with hibernate or other JPA vendor, does that mean that the queries are at least equally fast as working with stored procedures ? I read in many places that stored procedures are fastest way to query the database, but does this approach solves the problem in order to avoid using stored procedures ?
Upvotes: 1
Views: 1411
Reputation: 692003
No.
Stored procedures are not just queries. They're... procedures, that are executed in the database itself, as close to the data as they can.
JPQL named queries are validated and transformed to SQL queries at startup time. AFAIK, Spring-data-jpa queries are validated at startup time (but I'm not sure if they're transformed to SQL at startup time). Anyways, at runtime, they're still executed as SQL queries, just like the one you would execute yourself with JDBC prepared statements.
Upvotes: 4