无法读取更新的 AnyLogic DB 值 [英] Failure to Read Updated AnyLogic DB Values

查看:25
本文介绍了无法读取更新的 AnyLogic DB 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am currently using an AnyLogic database to store used parking capacity. I have written a function that reads the database and assigns an id to each container or trailer that is stored. Afterward, an UPDATE query is used to update the array.

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

The database read is performed using selectfrom() as specified by the database query tool. The UPDATE query is as follows:

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

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

This is based off of the example given in the AnyLogic help. storage is the database, id is the indexed column, trailer is the column with the relevant data.

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

When I run the simulation, the database updates as expected. However, in a select query within the same function or in a later call of the function, the value that the query reads is the value at the time of the beginning of the simulation. Is there a problem with my update query or can AnyLogic not read the update values while the simulation is ongoing?

推荐答案

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

selectFrom and other select queries use cached tables by default. Cache is not affected by update function, it changes original tables. You may force the functions to use non-cached tables using False value of boolean argument.

如果是 SQL 字符串,它是函数的第一个参数:

In case of SQL string it is the first argument of the function:

// 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 代码的情况下,它是最终函数的第一个参数:

In case of queryDSL Java code, it is the first argument of the final function:

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

这篇关于无法读取更新的 AnyLogic DB 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆