private Restriction buildRestriction(Object patternObject, Class<?> clazz) {
        Restriction query = new Restriction();

        if (patternObject != null) {

            for (ExtendedField field : DaoUtils.getAllFieldsWithSuperclasses(clazz)) {

                if (field.hasDBMapping()) {
                    Object value = field.getValue(patternObject);

                    if (value != null) {
                        query.addAnd();
                        query.add(whereRestriction(field.getDBFullQualifiedName(), value));
                    }
                }

                if (field.hasEntityMapping()) {
                    this.addEntityRestrictions(query, field, patternObject);
                }
            }
        }

        return query;
    }