fix: 修复自增主键并发线程问题
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>hcframe-base</artifactId>
|
||||
<version>1.2.5.3.2-SNAPSHOT</version>
|
||||
<version>1.2.5.3.3-SNAPSHOT</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
|
||||
@@ -896,7 +896,7 @@ public class BaseMapperImpl implements BaseMapper {
|
||||
if (map == null) {
|
||||
tableMapper.createHighGoSequence(tableName.toLowerCase(), 1);
|
||||
} else {
|
||||
tableMapper.createHighGoSequence(tableName.toLowerCase(), map.get(pkName));
|
||||
tableMapper.createHighGoSequence(tableName.toLowerCase(), Long.parseLong(String.valueOf(map.get(pkName)))+ 1);
|
||||
}
|
||||
}
|
||||
id = tableMapper.getHighGoSequence(tableName.toLowerCase());
|
||||
@@ -914,12 +914,12 @@ public class BaseMapperImpl implements BaseMapper {
|
||||
if (map == null) {
|
||||
tableMapper.createSequence(tableName, 1);
|
||||
} else {
|
||||
tableMapper.createSequence(tableName, map.get(pkName));
|
||||
tableMapper.createSequence(tableName, Long.parseLong(String.valueOf(map.get(pkName)))+ 1);
|
||||
}
|
||||
id = tableMapper.getSequence(tableName);
|
||||
}
|
||||
}
|
||||
return Long.parseLong(id.toString()) + 1L;
|
||||
return Long.parseLong(id.toString());
|
||||
}
|
||||
|
||||
private Map<String, Object> selectRecentData(String tableName, String pkName) {
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
NOCACHE
|
||||
</insert>
|
||||
<insert id="createHighGoSequence">
|
||||
CREATE SEQUENCE ${tableName}_seq
|
||||
CREATE SEQUENCE IF NOT EXISTS ${tableName}_seq
|
||||
MINVALUE 1
|
||||
NO MAXVALUE
|
||||
START WITH ${lastId}
|
||||
|
||||
Reference in New Issue
Block a user