public static DBObject convert(final Object entity) {
        final DBObject dbObject = new BasicDBObject();
        final Class<?> type = entity.getClass();


        if (!FIELD_CACHE.containsKey(type)) {
            // populate cache.
            final List<Field> declaredFields = getAllDeclaredFields(type);
            for (final Field field : declaredFields) {
                field.setAccessible(true);
            }
            FIELD_CACHE.put(type, declaredFields);
        }


        final List<Field> fields = FIELD_CACHE.get(type);
        for (final Field field : fields) {
            try {
                if (CoreEntity.class.isAssignableFrom(field.getType())) {
                    final CoreEntity centity = (CoreEntity) field.get(entity);
                    dbObject.put(field.getName(), centity.toDBObject());
                } else {
                    dbObject.put(field.getName(), field.get(entity));
                }
            } catch (IllegalArgumentException | IllegalAccessException ex) {
                LOGGER.error("Failed to get value of {}", field.getName(), ex);
            }
        }

        return dbObject;
    }