EntityLoad with 1 argument is supposed to return all records in a table.
However, if I call it immediately after an EntityNew and EntitySave (which inserts a new record) that last record appears to be missing from the results.
I get the record back fine if I instead pass in a filter or if I call EntityLoadByPk. I realize one would probably not want to get a record just inserted within the same request, but I would still like to know what is going on here.
local.e = EntityNew("e");
local.e.setDescription("lorem ipsum");
EntitySave(local.e);
local.id = local.e.getId();
//fails to get record inserted above
dump(EntityLoad("e"));
//gets record inserted above successfully
dump(EntityLoadByPk("e", local.id));
This has to do with Hibernate sessions and when the SQL to save an entity actually gets run. I am not an expert so its difficult to explain the ‘workflow’.
One way I use to get around this issue is to wrap the entitySave() in a transaction.