Map を返す関数を実装しようとしています。Long 値は 2 つの異なるシステムの ID です。Java Playframework 2 を使用しています。
データベースに 100 個のシステムがあるとします。クエリは、システムとの間に関係があるかどうかを検出し、SQL の出力は次のようになります。
1254 1380
1254 1389
1258 1259
1259 1258
1380 1254
これはマップだと思いますよね?
これが私の機能です:
public static Map<Long, Long> show_all_system_relations_between_systems() {
List <Infoobjectrelationtype> typeIdList = Infoobjectrelationtype.find.where().ilike("designation","is_a").findList();
Long typeId = typeIdList.get(0).infoobjectrelationtype_id;
List <Infoobject> ioList = Infoobject.find.where().ilike("designation","SYSTEM").findList();
Long systemId = ioList.get(0).infoobjectId;
SqlQuery query = Ebean.createSqlQuery("select distinct ir1.infoobject_id, ir2.infoobject_id from infoobjectrelation ir1, infoobjectrelation ir2 where ir1.related_infoobject_id = ir2.related_infoobject_id and ir1.related_infoobject_id !=" + systemId + " and ir1.infoobject_id != ir2.infoobject_id and ir1.infoobject_id in (select infoobject_id from infoobjectrelation where infoobjectrelationtype_id =" +typeId+ " and related_infoobject_id =" +systemId+ ") and ir2.infoobject_id in (select infoobject_id from infoobjectrelation where infoobjectrelationtype_id =" +typeId+ " and related_infoobject_id =" + systemId +") order by ir1.infoobject_id");
Map<Long, Long> rows = query.findMap();
return rows;
}
エラーメッセージ:
互換性のない型 [検出: java.util.Map< ? のキャプチャ #481、com.avaje.ebean.SqlRow> [必須: java.util.Map< java.lang.Long、java.lang.Long >]
この機能を動作させるにはどうすればよいですか? 代わりにリストを作成できますか?