문제

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?

올바른 솔루션이 없습니다

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top