Made generateSQLID synchronized and remember last generated ID in
DbMapping
This commit is contained in:
parent
06fd698c41
commit
4ca07eedc4
2 changed files with 5 additions and 2 deletions
|
@ -44,6 +44,7 @@ public class DbMapping {
|
||||||
private String idgen;
|
private String idgen;
|
||||||
// id generator for dbs that don't support sequences
|
// id generator for dbs that don't support sequences
|
||||||
private String sqlidgen;
|
private String sqlidgen;
|
||||||
|
public long lastID;
|
||||||
|
|
||||||
|
|
||||||
Schema schema = null;
|
Schema schema = null;
|
||||||
|
|
|
@ -478,7 +478,7 @@ public final class NodeManager {
|
||||||
/**
|
/**
|
||||||
* Generates an ID for the table by finding out the maximum current value
|
* Generates an ID for the table by finding out the maximum current value
|
||||||
*/
|
*/
|
||||||
public String generateSQLID (DbMapping map) throws Exception {
|
public synchronized String generateSQLID (DbMapping map) throws Exception {
|
||||||
|
|
||||||
Transactor tx = (Transactor) Thread.currentThread ();
|
Transactor tx = (Transactor) Thread.currentThread ();
|
||||||
// tx.timer.beginEvent ("generateID "+map);
|
// tx.timer.beginEvent ("generateID "+map);
|
||||||
|
@ -491,7 +491,9 @@ public final class NodeManager {
|
||||||
qds = new QueryDataSet (con, q);
|
qds = new QueryDataSet (con, q);
|
||||||
qds.fetchRecords ();
|
qds.fetchRecords ();
|
||||||
long currMax = qds.getRecord (0).getValue (1).asLong ();
|
long currMax = qds.getRecord (0).getValue (1).asLong ();
|
||||||
retval = Long.toString (currMax+1);
|
currMax = Math.max (currMax+1, map.lastID+1);
|
||||||
|
map.lastID = currMax;
|
||||||
|
retval = Long.toString (currMax);
|
||||||
} finally {
|
} finally {
|
||||||
// tx.timer.endEvent ("generateID "+map);
|
// tx.timer.endEvent ("generateID "+map);
|
||||||
if (qds != null) {
|
if (qds != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue