【发布时间】:2019-11-11 02:54:19
【问题描述】:
在我的 anylogic 项目中,我从内部数据库中查询数据集。我要查询的表结构如下:
Name: product_innovation_level
--------------------------------
ID|level_customer|level_employee|
--|--------------|--------------|
1| 10| 14|
我能找到的唯一示例使用元组类,如下所示。它可以工作,但感觉很笨拙,我必须从项目中手动提取所需的值。
Tuple innovationLevel = selectFrom(product_innovation_level).
where(product_innovation_level.id.eq(1)).
firstResult(product_innovation_level.level_customer, product_innovation_level.level_employee);
double ngEmployee = innovationLevel.get(product_innovation_level.level_employee);
double ngCustomer = innovationLevel.get(product_innovation_level.level_customer);
有没有更好的方法将值直接选择到模型类中?我正在寻找这样的东西:
xxx innovationLevel = selectFrom(product_innovation_level).
where(product_innovation_level.id.eq(1)).
firstResult(xxx);
我应该为 xxx 使用什么类?我找到了一个自动创建的类 Qproduct_innovation_level,但我没有找到访问该数据集值的方法。
Qproduct_innovation_level innovationLevel = selectFrom(product_innovation_level).
where(product_innovation_level.id.eq(1)).
firstResult(product_innovation_level);
int i = innovationLevel.level_customer.intValue();
Error: Type mismatch: cannot convert from NumberExpression<Integer> to int
我尝试自己编写模型类,但出现类型不匹配错误(无法从 Qproduct_innovation_level 转换为 InnovationLevelModel)。
【问题讨论】:
-
您的第二个代码 sn-p 这正是您直接执行此操作的方式(如果您知道您的查询仅返回 1 个值)。有什么问题?
-
嗨本杰明。我扩展了我的问题,我不知道分别使用什么类来访问所需的值。