我有一个看起来像这样的方法:
public static <T extends Enum<T> & Marshallable> String foo(Collection<T> collection, Class<? extends Marshallable>... marshallables);
Run Code Online (Sandbox Code Playgroud)
所以我期待传递的集合是一个实现Marshallable接口的Enum.如果我在运行时具有具体的Enum类型,它可以正常工作,但我编写了一个测试方法,它从类对象动态创建一个枚举列表(实现Marshallable),并且我无法将此列表传递给上面的方法.
@Test
public void fooTest() {
...
if (clazz.isEnum()) { // collection enum xml
List<? extends Enum<? extends Marshallable>> enumList = (List<? extends Enum<? extends Marshallable>>) Arrays.asList(clazz.getEnumConstants());
--> String enumListXml = foo(enumList, clazz);
...
Run Code Online (Sandbox Code Playgroud)
标记的行将给出编译错误.我无法弄清楚如何在不更改方法签名的情况下传递列表.
桌子:
create table properties
(
id int auto_increment primary key,
other_id int null
);
create index index_properties_on_other_id
on properties (other_id);
Run Code Online (Sandbox Code Playgroud)
TX 1:
start transaction;
SET @last_id = 1;
delete from `properties` WHERE `properties`.`other_id` = @last_id;
INSERT INTO `properties` (`other_id`) VALUES (@last_id);
commit
Run Code Online (Sandbox Code Playgroud)
发射2:
start transaction;
SET @last_id = 2;
delete from `properties` WHERE `properties`.`other_id` = @last_id;
INSERT INTO `properties` (`other_id`) VALUES (@last_id);
commit
Run Code Online (Sandbox Code Playgroud)
假设在运行事务之前表是空的。
我的应用程序有 2 个用例。有时last_id
已经被另一行使用,因此它会被优先索引;但有时它会由先前的插入查询在同一事务中生成,在这种情况下我会遇到死锁。
我需要运行这两个事务,直到删除语句之后。当我在 tx1 上运行 insert 时,它会等待获取锁,然后我在 tx2 上运行 insert,tx2 会出现死锁并回滚。
mysql | …
Run Code Online (Sandbox Code Playgroud)