2 回答
TA贡献1829条经验 获得超6个赞
您可以创建一个包装类来存储检索到的值:
class PrimaryKeyWrapper{
Record primaryKey;
public void setPrimaryKey(Record primaryKey) {
this.primaryKey = primaryKey;
}
public Record getPrimaryKey() {
return primaryKey;
}
}
并使用该类的实例从 lambda 函数内部存储此值:
PrimaryKeyWrapper primaryKeyWrapper = new PrimaryKeyWrapper();
dslContext.transaction(
c -> {
Record primaryKey = this.postgresService.insertData(c, table, map);
primaryKeyWrapper.setPrimaryKey(primaryKey);
});
最后,您可以从外部获取值:
primaryKeyWrapper.getPrimaryKey();
TA贡献1833条经验 获得超4个赞
只需使用transactionResult:
String primaryKey = dslContext.transactionResult(
(Configuration c) -> {
return this.postgresService.insertData(c, table, map);
});
添加回答
举报