@Override public Map<String, List<InstanceHostMap>> getInstanceHostMapsWithHostUuid(long instanceId) { Map<Record, List<InstanceHostMap>> result = create() .select(INSTANCE_HOST_MAP.fields()).select(HOST.UUID) .from(INSTANCE_HOST_MAP) .join(HOST).on(INSTANCE_HOST_MAP.HOST_ID.eq(HOST.ID)) .where(INSTANCE_HOST_MAP.INSTANCE_ID.eq(instanceId) .and(INSTANCE_HOST_MAP.REMOVED.isNull())) .fetchGroups(new Field[]{HOST.UUID}, InstanceHostMap.class); Map<String, List<InstanceHostMap>> maps = new HashMap<>(); for (Map.Entry<Record, List<InstanceHostMap>>entry : result.entrySet()) { String uuid = (String)entry.getKey().getValue(0); maps.put(uuid, entry.getValue()); } return maps; }
private final Table<Record> table(Configuration configuration) { if (table == null) { Select<Record> select = null; for (Object element : array) { // [#1081] Be sure to get the correct cast type also for null Field<?> val = DSL.val(element, field.fields[0].getDataType()); Select<Record> subselect = using(configuration).select(val.as("COLUMN_VALUE")).select(); if (select == null) { select = subselect; } else { select = select.unionAll(subselect); } } // Empty arrays should result in empty tables if (select == null) { select = using(configuration).select(one().as("COLUMN_VALUE")).select().where(falseCondition()); } table = select.asTable(alias); } return table; } }
private final Table<Record> table(Configuration configuration) { if (table == null) { Select<Record> select = null; for (Object element : array) { // [#1081] Be sure to get the correct cast type also for null Field<?> val = DSL.val(element, field.fields[0].getDataType()); Select<Record> subselect = using(configuration).select(val.as("COLUMN_VALUE")).select(); if (select == null) { select = subselect; } else { select = select.unionAll(subselect); } } // Empty arrays should result in empty tables if (select == null) { select = using(configuration).select(one().as("COLUMN_VALUE")).select().where(falseCondition()); } table = DSL.table(select).as(alias); } return table; } }