0

I am looking for a way to overload several queries from my jpa repository. for example i want to have the "regular" : public Player findPlayerById(Long Id); but also :

 @Lock(LockModeType.PESSIMISTIC_WRITE)
    public Player findPlayerById(Long Id);

I found this: How to add custom method to Spring Data JPA but i don't think its relevant for my case. I thought about creating PlayerRepositoryPessimestic with the locked annotation.

Is there a way to use the same repository?

Community
  • 1
  • 1
lior
  • 1,127
  • 3
  • 24
  • 43

1 Answers1

0

I think here your problem is more a Java problem.

Both

@Lock(LockModeType.PESSIMISTIC_WRITE)
public Player findPlayerById(Long Id);

and

public Player findPlayerById(Long Id);

have the same signature. So my guess is that it is not possible using the same repo. But there are plenty options. Different repos as you suggest is the easiest one IMO. But you could write a custom InvocationHandler.

ssedano
  • 8,322
  • 9
  • 60
  • 98