Browse Source
Methods which use the derive query functionality now can be annotated with `@Lock` to used a given `LockMode`. Right now there are two different modes `PESSIMISTIC_READ` and `PESSIMISTIC_WRITE`. Based on the dialect the right select is generated. For example for HSQLDB `Select ... FOR UPDATE`. See #1041 Original pull request #1158pull/1166/head
8 changed files with 184 additions and 21 deletions
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
/* |
||||
* Copyright 2022 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.data.jdbc.repository.query; |
||||
|
||||
import org.springframework.data.annotation.QueryAnnotation; |
||||
import org.springframework.data.relational.core.sql.LockMode; |
||||
|
||||
import java.lang.annotation.*; |
||||
|
||||
/** |
||||
* Annotation to provide a lock mode for a given query. |
||||
* |
||||
* @author Diego Krupitza |
||||
*/ |
||||
@Retention(RetentionPolicy.RUNTIME) |
||||
@Target(ElementType.METHOD) |
||||
@QueryAnnotation |
||||
@Documented |
||||
public @interface Lock { |
||||
|
||||
/** |
||||
* Defines which type of {@link LockMode} we want to use. |
||||
*/ |
||||
LockMode value() default LockMode.PESSIMISTIC_READ; |
||||
|
||||
} |
||||
Loading…
Reference in new issue