コード例 #1
0
 public ResultMap resolveDiscriminatedResultMap(
     ResultSet rs, ResultMap resultMap, String columnPrefix) throws SQLException {
   Set<String> pastDiscriminators = new HashSet<String>();
   Discriminator discriminator = resultMap.getDiscriminator();
   while (discriminator != null) {
     final Object value = getDiscriminatorValue(rs, discriminator, columnPrefix);
     final String discriminatedMapId = discriminator.getMapIdFor(String.valueOf(value));
     if (configuration.hasResultMap(discriminatedMapId)) {
       resultMap = configuration.getResultMap(discriminatedMapId);
       Discriminator lastDiscriminator = discriminator;
       discriminator = resultMap.getDiscriminator();
       if (discriminator == lastDiscriminator || !pastDiscriminators.add(discriminatedMapId)) {
         break;
       }
     } else {
       break;
     }
   }
   return resultMap;
 }
コード例 #2
0
 private Object getDiscriminatorValue(
     ResultSet rs, Discriminator discriminator, String columnPrefix) throws SQLException {
   final ResultMapping resultMapping = discriminator.getResultMapping();
   final TypeHandler<?> typeHandler = resultMapping.getTypeHandler();
   return typeHandler.getResult(rs, prependPrefix(resultMapping.getColumn(), columnPrefix));
 }