jodd-db/src/main/java/jodd/db/oom/mapper/DefaultResultSetMapper.java
@Override
	public Object[] parseObjects(final Class... types) {
		resultColumns.clear();

		int totalTypes = types.length;
		Object[] result = new Object[totalTypes];
		boolean[] resultUsage = new boolean[totalTypes];
		DbEntityDescriptor[] dbEntityDescriptors = resolveDbEntityDescriptors(types);
		String[] typesTableNames = resolveTypesTableNames(types);
		String[][] mappedNames = resolveMappedTypesTableNames(types);

		int currentResult = 0;
		cachedColumnNdx = -1;
		int colNdx = 0;
		while (colNdx < totalColumns) {

			// no more types for mapping?
			if (currentResult >= totalTypes) {
				break;
			}

			// skip columns that doesn't map
			Class currentType = types[currentResult];
			if (currentType == null) {
				colNdx++;
				currentResult++;
				resultColumns.clear();
				continue;
			}

			String columnName = columnNames[colNdx];
			int columnDbSqlType = columnDbSqlTypes[colNdx];
			String tableName = tableNames[colNdx];
			String resultTableName = typesTableNames[currentResult];			

			if (resultTableName == null) {
				// match: simple type
				result[currentResult] = readColumnValue(colNdx, currentType, null, columnDbSqlType);
				resultUsage[currentResult] = true;
				colNdx++;
				currentResult++; resultColumns.clear();
				continue;
			}

			// match table
			boolean tableMatched = false;

			if (tableName == null) {
				tableMatched = true;
			} else if (resultTableName.equals(tableName)) {
				tableMatched = true;
			} else {
				String[] mapped = mappedNames[currentResult];
				if (mapped != null) {
					for (String m : mapped) {
						if (m.equals(tableName)) {
							tableMatched = true;
							break;
						}
					}
				}
			}

			if (tableMatched) {
				if (!resultColumns.contains(columnName)) {
					//DbEntityDescriptor ded = dbEntityManager.lookupType(currentType);
					DbEntityDescriptor ded = dbEntityDescriptors[currentResult];

					DbEntityColumnDescriptor dec = ded.findByColumnName(columnName);
					String propertyName = (dec == null ? null : dec.getPropertyName());

					// check if a property that matches column name exist
					if (propertyName != null) {

						// if current entity instance does not exist (i.e. we are at the first column
						// of some entity), create the instance and store it
						if (result[currentResult] == null) {
							result[currentResult] = dbEntityManager.createEntityInstance(currentType);
						}
/*
						boolean success = value != null ?
										BeanUtil.setDeclaredPropertySilent(result[currentResult], propertyName, value) :
										BeanUtil.hasDeclaredProperty(result[currentResult], propertyName);
*/
						Class type = BeanUtil.declared.getPropertyType(result[currentResult], propertyName);
						if (type != null) {
							// match: entity
							dec.updateDbSqlType(columnDbSqlType);	// updates column db sql type information for the entity!!!
							Class<? extends SqlType> sqlTypeClass = dec.getSqlTypeClass();
							Object value = readColumnValue(colNdx, type, sqlTypeClass, columnDbSqlType);

							if (value != null) {
								// inject column value into existing entity
								BeanUtil.declared.setProperty(result[currentResult], propertyName, value);
								resultUsage[currentResult] = true;
							}
							colNdx++;
							resultColumns.add(columnName);
							continue;
						}
					}
				}
			}
			// go to next type, i.e. result
			currentResult++;
			resultColumns.clear();
		}

		resultColumns.clear();
		for (int i = 0; i < resultUsage.length; i++) {
			if (!resultUsage[i]) {
				result[i] = null;
			}
		}

		if (cacheEntities) {
			cacheResultSetEntities(result);
		}

		return result;
	}
@Override
	public Object[] parseObjects(final Class... types) {
		resultColumns.clear();

		int totalTypes = types.length;
		Object[] result = new Object[totalTypes];
		boolean[] resultUsage = new boolean[totalTypes];
		DbEntityDescriptor[] dbEntityDescriptors = resolveDbEntityDescriptors(types);
		String[] typesTableNames = resolveTypesTableNames(types);
		String[][] mappedNames = resolveMappedTypesTableNames(types);

		int currentResult = 0;
		cachedColumnNdx = -1;
		int colNdx = 0;
		while (colNdx < totalColumns) {

			// no more types for mapping?
			if (currentResult >= totalTypes) {
				break;
			}

			// skip columns that doesn't map
			Class currentType = types[currentResult];
			if (currentType == null) {
				colNdx++;
				currentResult++;
				resultColumns.clear();
				continue;
			}

			String columnName = columnNames[colNdx];
			int columnDbSqlType = columnDbSqlTypes[colNdx];
			String tableName = tableNames[colNdx];
			String resultTableName = typesTableNames[currentResult];			

			if (resultTableName == null) {
				// match: simple type
				result[currentResult] = readColumnValue(colNdx, currentType, null, columnDbSqlType);
				resultUsage[currentResult] = true;
				colNdx++;
				currentResult++; resultColumns.clear();
				continue;
			}

			// match table
			boolean tableMatched = false;

			if (tableName == null) {
				tableMatched = true;
			} else if (resultTableName.equals(tableName)) {
				tableMatched = true;
			} else {
				String[] mapped = mappedNames[currentResult];
				if (mapped != null) {
					for (String m : mapped) {
						if (m.equals(tableName)) {
							tableMatched = true;
							break;
						}
					}
				}
			}

			if (tableMatched) {
				if (!resultColumns.contains(columnName)) {
					//DbEntityDescriptor ded = dbEntityManager.lookupType(currentType);
					DbEntityDescriptor ded = dbEntityDescriptors[currentResult];

					DbEntityColumnDescriptor dec = ded.findByColumnName(columnName);
					String propertyName = (dec == null ? null : dec.getPropertyName());

					// check if a property that matches column name exist
					if (propertyName != null) {

						// if current entity instance does not exist (i.e. we are at the first column
						// of some entity), create the instance and store it
						if (result[currentResult] == null) {
							result[currentResult] = dbEntityManager.createEntityInstance(currentType);
						}
/*
						boolean success = value != null ?
										BeanUtil.setDeclaredPropertySilent(result[currentResult], propertyName, value) :
										BeanUtil.hasDeclaredProperty(result[currentResult], propertyName);
*/
						Class type = BeanUtil.declared.getPropertyType(result[currentResult], propertyName);
						if (type != null) {
							// match: entity
							dec.updateDbSqlType(columnDbSqlType);	// updates column db sql type information for the entity!!!
							Class<? extends SqlType> sqlTypeClass = dec.getSqlTypeClass();
							Object value = readColumnValue(colNdx, type, sqlTypeClass, columnDbSqlType);

							if (value != null) {
								// inject column value into existing entity
								BeanUtil.declared.setProperty(result[currentResult], propertyName, value);
								resultUsage[currentResult] = true;
							}
							colNdx++;
							resultColumns.add(columnName);
							continue;
						}
					}
				}
			}
			// go to next type, i.e. result
			currentResult++;
			resultColumns.clear();
		}

		resultColumns.clear();
		for (int i = 0; i < resultUsage.length; i++) {
			if (!resultUsage[i]) {
				result[i] = null;
			}
		}

		if (cacheEntities) {
			cacheResultSetEntities(result);
		}

		return result;
	}
@ Override public Object [ ] parseObjects ( final Class ... types ) { resultColumns . clear ( ) ; int totalTypes = types . length ; Object [ ] result = new Object [ totalTypes ] ; boolean [ ] resultUsage = new boolean [ totalTypes ] ; DbEntityDescriptor [ ] dbEntityDescriptors = resolveDbEntityDescriptors ( types ) ; String [ ] typesTableNames = resolveTypesTableNames ( types ) ; String [ ] [ ] mappedNames = resolveMappedTypesTableNames ( types ) ; int currentResult = 0 ; cachedColumnNdx = - 1 ; int colNdx = 0 ; while ( colNdx < totalColumns ) { // no more types for mapping? if ( currentResult >= totalTypes ) { break ; } // skip columns that doesn't map Class currentType = types [ currentResult ] ; if ( currentType == null ) { colNdx ++ ; currentResult ++ ; resultColumns . clear ( ) ; continue ; } String columnName = columnNames [ colNdx ] ; int columnDbSqlType = columnDbSqlTypes [ colNdx ] ; String tableName = tableNames [ colNdx ] ; String resultTableName = typesTableNames [ currentResult ] ; if ( resultTableName == null ) { // match: simple type result [ currentResult ] = readColumnValue ( colNdx , currentType , null , columnDbSqlType ) ; resultUsage [ currentResult ] = true ; colNdx ++ ; currentResult ++ ; resultColumns . clear ( ) ; continue ; } // match table boolean tableMatched = false ; if ( tableName == null ) { tableMatched = true ; } else if ( resultTableName . equals ( tableName ) ) { tableMatched = true ; } else { String [ ] mapped = mappedNames [ currentResult ] ; if ( mapped != null ) { for ( String m : mapped ) { if ( m . equals ( tableName ) ) { tableMatched = true ; break ; } } } } if ( tableMatched ) { if ( ! resultColumns . contains ( columnName ) ) { //DbEntityDescriptor ded = dbEntityManager.lookupType(currentType); DbEntityDescriptor ded = dbEntityDescriptors [ currentResult ] ; DbEntityColumnDescriptor dec = ded . findByColumnName ( columnName ) ; String propertyName = ( dec == null ? null : dec . getPropertyName ( ) ) ; // check if a property that matches column name exist if ( propertyName != null ) { // if current entity instance does not exist (i.e. we are at the first column // of some entity), create the instance and store it if ( result [ currentResult ] == null ) { result [ currentResult ] = dbEntityManager . createEntityInstance ( currentType ) ; } /*
						boolean success = value != null ?
										BeanUtil.setDeclaredPropertySilent(result[currentResult], propertyName, value) :
										BeanUtil.hasDeclaredProperty(result[currentResult], propertyName);
*/ Class type = BeanUtil . declared . getPropertyType ( result [ currentResult ] , propertyName ) ; if ( type != null ) { // match: entity dec . updateDbSqlType ( columnDbSqlType ) ; // updates column db sql type information for the entity!!! Class < ? extends SqlType > sqlTypeClass = dec . getSqlTypeClass ( ) ; Object value = readColumnValue ( colNdx , type , sqlTypeClass , columnDbSqlType ) ; if ( value != null ) { // inject column value into existing entity BeanUtil . declared . setProperty ( result [ currentResult ] , propertyName , value ) ; resultUsage [ currentResult ] = true ; } colNdx ++ ; resultColumns . add ( columnName ) ; continue ; } } } } // go to next type, i.e. result currentResult ++ ; resultColumns . clear ( ) ; } resultColumns . clear ( ) ; for ( int i = 0 ; i < resultUsage . length ; i ++ ) { if ( ! resultUsage [ i ] ) { result [ i ] = null ; } } if ( cacheEntities ) { cacheResultSetEntities ( result ) ; } return result ; }
{@inheritDoc}
{