|
|
|
@ -289,10 +289,11 @@ public class SqliteDb extends BaseDb implements StockDb { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public DbLocation save(DbLocation location) { |
|
|
|
public DbLocation save(DbLocation location) { |
|
|
|
|
|
|
|
var parentId = location.parent() == 0 ? null : location.parent(); |
|
|
|
if (location.id() == 0) { // new location
|
|
|
|
if (location.id() == 0) { // new location
|
|
|
|
try { |
|
|
|
try { |
|
|
|
var rs = insertInto(TABLE_LOCATIONS,OWNER,PARENT_LOCATION_ID,NAME,DESCRIPTION) |
|
|
|
var rs = insertInto(TABLE_LOCATIONS,OWNER,PARENT_LOCATION_ID,NAME,DESCRIPTION) |
|
|
|
.values(location.owner().dbCode(),location.parent(),location.name(),location.description()) |
|
|
|
.values(location.owner().dbCode(),location.parent() == 0 ? null : parentId,location.name(),location.description()) |
|
|
|
.execute(db).getGeneratedKeys(); |
|
|
|
.execute(db).getGeneratedKeys(); |
|
|
|
long id = 0; |
|
|
|
long id = 0; |
|
|
|
if (rs.next()) id = rs.getLong(1); |
|
|
|
if (rs.next()) id = rs.getLong(1); |
|
|
|
@ -308,7 +309,7 @@ public class SqliteDb extends BaseDb implements StockDb { |
|
|
|
.set(OWNER, PARENT_LOCATION_ID, NAME, DESCRIPTION) |
|
|
|
.set(OWNER, PARENT_LOCATION_ID, NAME, DESCRIPTION) |
|
|
|
.where(ID,equal(location.id())) |
|
|
|
.where(ID,equal(location.id())) |
|
|
|
.prepare(db) |
|
|
|
.prepare(db) |
|
|
|
.apply(location.owner().dbCode(), location.parent(), location.name(), location.description()) |
|
|
|
.apply(location.owner().dbCode(), parentId, location.name(), location.description()) |
|
|
|
.close(); |
|
|
|
.close(); |
|
|
|
return location.clear(); |
|
|
|
return location.clear(); |
|
|
|
} catch (SQLException e){ |
|
|
|
} catch (SQLException e){ |
|
|
|
|