Reputation: 63
I am using Spring Data JPA. I am using normalized DB which means, to get a full details of what i want, i have to join many tables. As you know JPA generates method name based on query. But, due to multiple joins, my method name becomes so long. sometimes, its more than 250 chars. I am looking for @query annotation with JPA methods instead of auto generated JPA method names. I wanna know the performance implications if i use @query annotation? Also, please suggest any alternatives to solve my long method names keeping performance into consideration.
Upvotes: 3
Views: 2843
Reputation: 2571
Whenever you write your query using Spring Data (i.e List<MyObj> findAllByName(String name)
) spring data actually generates your query the same way as you'd write it using @Query
annotation. So, technically speaking, boot-up time will be quicker if you write your queries as HQL
or JPQL
within @Query
annotation. The most performant way is of course to use native queries, but it can be a pain in the ass later in the game.
Upvotes: 1