我目前正在使用 AnyLogic 数据库来存储已用停车容量。我编写了一个函数来读取数据库并为每个存储的集装箱或拖车分配一个 id。然后,使用 UPDATE 查询来更新数组。
数据库读取是使用数据库查询工具指定的 selectfrom() 执行的。 UPDATE查询如下:
update(storage)
.where(storage.id.eq(ret%1000/10))
.set(storage.trailer, 1)
.execute();
这是基于 AnyLogic 帮助中给出的示例。 storage 是数据库,id 是索引列,trailer 是包含相关数据的列。
当我运行模拟时,数据库按预期更新。但是,在同一函数内或稍后调用该函数的选择查询中,查询读取的值是模拟开始时的值。我的更新查询是否有问题,或者在模拟进行时 AnyLogic 无法读取更新值?
selectFrom
和其他选择查询默认使用缓存表。缓存不受update
函数,它改变了原始表。您可以强制函数使用非缓存表False
布尔参数的值。
对于 SQL 字符串,它是函数的第一个参数:
// read from cache
selectUniqueValue( double.class, "SELECT processing_time FROM processing_times WHERE part = agent.name;"); // or
selectUniqueValue( true, double.class, "SELECT processing_time FROM processing_times WHERE part = agent.name;");
// read from original
selectUniqueValue( false, double.class, "SELECT processing_time FROM processing_times WHERE part = agent.name;");
对于 queryDSL Java 代码,它是最终函数的第一个参数:
// read from cache
selectFrom(branches)
.where(branches.al_id.eq(9))
.firstResult( branches.branch ); // or
selectFrom(branches)
.where(branches.al_id.eq(9))
.firstResult( true, branches.branch );
// read from original
selectFrom(branches)
.where(branches.al_id.eq(9))
.firstResult( false, branches.branch );
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)