Generate multiple valid IDs in generateMaxID() when the
prototype's table is empty. Previously, new IDs for empty tables always returned 0. This fixes bug 59. http://helma.org/bugs/show_bug.cgi?id=59
This commit is contained in:
parent
896e5e1854
commit
ced9315833
1 changed files with 12 additions and 6 deletions
|
@ -579,11 +579,14 @@ public final class NodeManager {
|
||||||
qds = new QueryDataSet (con, q);
|
qds = new QueryDataSet (con, q);
|
||||||
qds.fetchRecords ();
|
qds.fetchRecords ();
|
||||||
// check for empty table
|
// check for empty table
|
||||||
if (qds.size () == 0)
|
if (qds.size () == 0) {
|
||||||
return "0";
|
long currMax = map.getNewID (0);
|
||||||
long currMax = qds.getRecord (0).getValue (1).asLong ();
|
retval = Long.toString (currMax);
|
||||||
currMax = map.getNewID (currMax);
|
} else {
|
||||||
retval = Long.toString (currMax);
|
long currMax = qds.getRecord (0).getValue (1).asLong ();
|
||||||
|
currMax = map.getNewID (currMax);
|
||||||
|
retval = Long.toString (currMax);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
// tx.timer.endEvent ("generateID "+map);
|
// tx.timer.endEvent ("generateID "+map);
|
||||||
if (qds != null) {
|
if (qds != null) {
|
||||||
|
@ -594,6 +597,9 @@ public final class NodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a new ID from an Oracle sequence.
|
||||||
|
*/
|
||||||
public String generateID (DbMapping map) throws Exception {
|
public String generateID (DbMapping map) throws Exception {
|
||||||
|
|
||||||
Transactor tx = (Transactor) Thread.currentThread ();
|
Transactor tx = (Transactor) Thread.currentThread ();
|
||||||
|
@ -606,7 +612,7 @@ public final class NodeManager {
|
||||||
String q = "SELECT "+map.getIDgen()+".nextval FROM dual";
|
String q = "SELECT "+map.getIDgen()+".nextval FROM dual";
|
||||||
qds = new QueryDataSet (con, q);
|
qds = new QueryDataSet (con, q);
|
||||||
qds.fetchRecords ();
|
qds.fetchRecords ();
|
||||||
retval = qds.getRecord (0).getValue (1).asString ();
|
retval = qds.getRecord (0).getValue (1).asString ();
|
||||||
} 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