Question

I would like to use the built in query creation from method names, for example:

public Person findByFirstName(String firstName);

But I want to mark specific queries "for update" meaning to use:

public Person findByFirstNameForUpdate(String firstName);

Is there a way to make it work? I know I can create a new repository "PersonRepositoryForUpdate" but can I use the same repository?

No correct solution

OTHER TIPS

You can add the @Query annotation above the method and use any query and any name for the method.

@Query("select ...")
public Person findGiveAnyName(String firstName);

The query can be written in JPQL or SQL.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top