- changed status to resolved
Sequence value is looked up but the Parameter Value for Sequence is never set into the insert params
Issue #63
closed
When the [Sequence] attribute is used the code is getting the next sequence and setting it into the ID Column of the entity correctly, but the Parameters set on the insert statement do not include this value.
After researching the code it seems that the Parameter list is being built before the Sequence value is retrieved in the Spring.Persistence.SQL.Commands.Insert.TInsertExecutor.Execute method
procedure TInsertExecutor.Execute(const entityWrapper: IEntityWrapper);
var
statement: IDBStatement;
resultSet: IDBResultSet;
queryText: string;
value: TValue;
begin
BuildParams(entityWrapper.GetEntity);
if EntityData.HasVersionColumn then
entityWrapper.SetColumnValue(EntityData.VersionColumn, 0);
value := GetAutogeneratedPrimaryKeyValue(entityWrapper);
if not value.IsEmpty then
entityWrapper.SetPrimaryKeyValue(value);
Moving the call to BuildParams below the call to entityWrapper.SetPrimakyKeyValue seems to resolve the issue.
procedure TInsertExecutor.Execute(const entityWrapper: IEntityWrapper);
var
statement: IDBStatement;
resultSet: IDBResultSet;
queryText: string;
value: TValue;
begin
// BuildParams(entityWrapper.GetEntity); {<-Move this Line Down}
if EntityData.HasVersionColumn then
entityWrapper.SetColumnValue(EntityData.VersionColumn, 0);
value := GetAutogeneratedPrimaryKeyValue(entityWrapper);
if not value.IsEmpty then
entityWrapper.SetPrimaryKeyValue(value);
BuildParams(entityWrapper.GetEntity); {<--Inserted Here after the call to GetAutoGen and setting value into Entity}
Comments (2)
-
-
repo owner - changed status to closed
- Log in to comment
fixes
#63→ <<cset 7a3bfad2b871>>