是否有可能在spring-data存储库中有两个方法 - 一个没有锁定T findOne(Predicate p);
但同时锁定@Lock(LockModeType.PESSIMISTIC_WRITE) T findOne(Predicate p);
?
我希望有像
这样的东西public interface TransactionRepository extends JpaRepository<Transaction, String>,
QueryDslPredicateExecutor<Transaction> {
@Lock(LockModeType.PESSIMISTIC_WRITE)
@AliasFor("findOne")
Transaction findOne_withLock(Predicate p);
}
答案 0 :(得分:0)
不,它不可能
Java不允许您使用相同的原型定义两个函数。 U可以有一个选择器,它根据一些环境变量调用函数
scala> val df = spark.read.json("data.json")
scala> df.printSchema
root
|-- a: struct (nullable = true)
| |-- b: struct (nullable = true)
| | |-- c: long (nullable = true)
|-- **TimeStamp: string (nullable = true)**
|-- id: string (nullable = true)
scala> val df1 = df.withColumn("TimeStamp", $"TimeStamp".cast(TimestampType))
scala> df1.printSchema
root
|-- a: struct (nullable = true)
| |-- b: struct (nullable = true)
| | |-- c: long (nullable = true)
|-- **TimeStamp: timestamp (nullable = true)** // WORKING AS EXPECTED
|-- id: string (nullable = true)
scala> val df2 = df.withColumn("a.b.c", $"a.b.c".cast(DoubleType))
scala> df2.printSchema
root
|-- a: struct (nullable = true)
| |-- b: struct (nullable = true)
| | |-- c: long (nullable = true)
|-- TimeStamp: string (nullable = true)
|-- id: string (nullable = true)
|-- **a.b.c: double (nullable = true)** // DUPLICATE COLUMN ADDED