class KeyHolder {

    public static void setGeneratedKeyBack(DaoTask<?> task, Hints hints, List<?> rawPojos) throws SQLException {
        if (!(task instanceof KeyHolderAwaredTask)) {
            return;
        }

        KeyHolder keyHolder = hints.getKeyHolder();

        if (keyHolder == null || rawPojos == null || rawPojos.isEmpty()) {
            return;
        }

        if (!(hints.is(HintEnum.setIdentityBack) && hints.isIdentityInsertDisabled())) {
            return;
        }

        //Handle remote Entities
        Object obj = rawPojos.get(0);
        if(obj.getClass() == Entity.class) {
            Entity entity = (Entity) obj;
            com.ppdai.das.service.EntityMeta meta = entity.getEntityMeta();

            List<Map<String, Object>> maps = ConvertUtils.entity2POJOs((List<Entity>)rawPojos, meta, Map.class);
            String key = meta.getPrimaryKeyNames().get(0);
            String type = meta.getMetaMap().get(key).getType();
            for (int i = 0; i < rawPojos.size(); i++){
                if (!isEmptyKey(keyHolder, i)) {
                    setPrimaryKey(type, key, maps.get(i), keyHolder.getKey(i));
                    Entity newEntity = ConvertUtils.pojo2Entity(maps.get(i), meta);
                    ((Entity)rawPojos.get(i)).setValue(newEntity.getValue());
                }
            }
            return;
        }

        EntityMeta em = EntityMetaManager.extract(rawPojos.get(0).getClass());
        if (em.getPrimaryKeyNames().length == 0) {
            throw new IllegalArgumentException(
                    "insertIdentityBack only support JPA POJO. Please use code gen to regenerate your POJO");
        }

        Field pkFlield = em.getFieldMap().get(em.getPrimaryKeyNames()[0]);

        if (pkFlield == null) {
            throw new IllegalArgumentException(
                    "insertIdentityBack only support JPA POJO. Please use code gen to regenerate your POJO");
        }

        for (int i = 0; i < rawPojos.size(); i++) {
            if (!isEmptyKey(keyHolder, i)) {
                setPrimaryKey(pkFlield, rawPojos.get(i), keyHolder.getKey(i));
            }
        }
    }

    public  KeyHolder();

}