私はテーブルを持っている:jOOQ - カラムとテーブルを関数に渡すには?私のデータベースで
CREATE TABLE calibration_factor_pm1
(
sensor_id Integer REFERENCES sensor(id),
factor_a double precision NOT NULL,
factor_b double precision NOT NULL,
time_from_which_factor_is_used timestamp NOT NULL
)
そして私は、私は要因(AまたはB)Iに関する情報を渡すことができますするためにどの機能を作りたい、このようないくつかの他のテーブルが存在しますので、どのテーブルからフェッチしたいか。
私は、このようにそれを行うにしようとしていた。
private Double getCalibrationFactor(String sensorId, TableField<Record, TableImpl> factor, TableImpl PM, TableField<Record, TableImpl> sensorIdTableField, TableField<Record, TableImpl> timeFromWhichFactorIsUsed) {
Double calibrationFactorAPM1 = 1.0;
try {
calibrationFactorAPM1 = Double.valueOf(Database.create
.select(factor) //CalibrationFactorPm1.CALIBRATION_FACTOR_PM1.FACTOR_A
.from(PM) //CalibrationFactorPm1.CALIBRATION_FACTOR_PM1
.where(sensorIdTableField.equal(Integer.valueOf(sensorId)))
.orderBy(timeFromWhichFactorIsUsed.desc())
.fetchOne()
.getValue(0)
.toString());
} catch (NullPointerException e) {
System.out.println("DEBUG: Can't find calibration factor 'a' for this sensor");
e.printStackTrace();
}
}
しかし、私は.where(sensorIdTableField.equal(Integer.valueOf(sensorId)))
ライン上Cannot resolve method 'equal(java.lang.Integer)'
を取得します。
これに正しくアプローチするにはどうすればよいですか?
@edit
あなたのスキーマを考えると、私は 'equal'が' Integer'ではなく 'Double'を期待していると思います。 'sensorIdTableField.equal(Integer.valueOf(sensorId).doubleValue))')おそらく動作します。 – assylias
いいえ、動作していません。その質問を、「同等」が何を期待しているかを示すイメージで更新しました。 – Defozo
Ha申し訳ありませんが速すぎます。メソッドのシグネチャを 'Field sensorIdTableField'を使用して変更できる場合は、問題を解決するはずです。 –
assylias