首页 文章

无法读取更新的AnyLogic数据库值

提问于
浏览
1

我目前正在使用AnyLogic数据库来存储二手停车容量 . 我编写了一个函数来读取数据库并为每个存储的容器或预告片分配一个id . 之后,UPDATE查询用于更新阵列 .

使用数据库查询工具指定的selectfrom()执行数据库读取 . UPDATE查询如下:

update(storage)
        .where(storage.id.eq(ret%1000/10))
        .set(storage.trailer, 1)
        .execute();

这是基于AnyLogic帮助中给出的示例 . storage是数据库,id是索引列,trailer是包含相关数据的列 .

当我运行模拟时,数据库按预期更新 . 但是,在同一函数内或稍后调用函数的select查询中,查询读取的值是模拟开始时的值 . 我的更新查询是否有问题,或者AnyLogic在模拟过程中是否无法读取更新值?

1 回答

  • 0

    selectFrom 和其他选择查询默认使用缓存表 . 缓存不受 update 函数的影响,它会更改原始表 . 您可以使用 False boolean参数值强制函数使用非缓存表 .

    在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 );
    

相关问题