What are my options for the key in "fetchMap(key, record)"?

I was getting duplicates (of what, we'll confess later) so I added the "Distinct" seen below

      /*
       * We believe all current person.name values are also in alias.aka
       */
      private Map<String, PersonRecord> readKnowPersons(Map<String,
   LinkageIndividual> pedIndivMap) {
        Map<String, PersonRecord> fullMap = new HashMap<>();
        fullMap.putAll(ctx.selectDistinct()
          .from(PERSON)
          .join(ALIAS).on(PERSON.ID.equal(ALIAS.PERSON_ID))
          .where(ALIAS.AKA.in(pedIndivMap.keySet()))
          .fetchMap(ALIAS.AKA, r -> r.into(PERSON)));
        return fullMap;
      }

The duplicates are actually in the ALIAS.AKA so I went to

      private Map<String, PersonRecord> readKnowPersons(Map<String,
   LinkageIndividual> pedIndivMap) {
        //Apologies for the selectDistinct.  If pedigrees overlap ALIAS
   may have multiple records
        //for one person, all with the same AKA - one per overlapped
   pedigree.  ALIAS is unique on
        //id/people_id.
        CommonTableExpression<Record2<String, UUID>> aka =
   name("aka").fields("aka","aid")
          .as(selectDistinct(ALIAS.AKA, ALIAS.PERSON_ID)
          .from(ALIAS)
          .where(ALIAS.AKA.in(pedIndivMap.keySet())));

        Map<String, PersonRecord> fullMap = new HashMap<>();
        fullMap.putAll(ctx.with(aka)
               .select()
               .from(PERSON)
   .join(aka).on(aka.field("aid").cast(UUID.class).equal(PERSON.ID))
               .fetchMap(aka.field("aka").cast(String.class), r ->
   r.into(PERSON)));
        return fullMap;
      }

The need to cast the fields of the CTE have me thinking I've done something incorrectly.
Sheer paranoia?

rjs

--
You received this message because you are subscribed to the Google Groups "jOOQ User 
Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/94c55220-f025-c4b5-093e-8101f85bc527%40gmail.com.

Reply via email to