public static <T> T createObject(AdapterBase adapter,ObjectRowMap cache, HashMap<String, Object> map, Class<T> resultClass,ConnectionWrapper cw,String tableName, Long dbId)
			throws SQLException
	{
		try
		{
			if (ObjectTools.isDatabasePrimitive(resultClass))
			{
				return resultClass.cast(map.get(Defaults.VALUE_COL));
			}
			else
			{
				// create a new object using the default constructor.
				Constructor<T> constructor = resultClass.getDeclaredConstructor();
				boolean wasAccessible = constructor.isAccessible();
				if(!wasAccessible)
				{
					//if the constructor is private, make it accessible
					constructor.setAccessible(true);
				}
				T res = constructor.newInstance();
				if(!wasAccessible)
				{
					constructor.setAccessible(wasAccessible);
				}
				// add object to cache
				cache.storeObject(tableName, res, dbId);
				fillObjectValues(adapter,cache, res, resultClass, map,cw);
				return res;
			}
		}
		catch (Exception e)
		{
			throw new SQLException(e);
		}
	}