我正在尝试实现一个应该返回 Map 的函数,Long 值是两个不同系统的 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< capture#481 of ?, com.avaje.ebean.SqlRow> [必需:java.util.Map< java.lang.Long, java.lang.Long >]
我怎样才能使这个功能工作?我可以列出它吗?