Search in sources :

Example 1 with BeanMap

use of com.querydsl.core.util.BeanMap in project querydsl by querydsl.

the class CollUpdateClause method execute.

@Override
public long execute() {
    int rv = 0;
    for (T match : query.fetch()) {
        BeanMap beanMap = new BeanMap(match);
        for (Map.Entry<Path<?>, Object> entry : paths.entrySet()) {
            // TODO : support deep updates as well
            String propertyName = entry.getKey().getMetadata().getName();
            beanMap.put(propertyName, entry.getValue());
        }
        rv++;
    }
    return rv;
}
Also used : Path(com.querydsl.core.types.Path) BeanMap(com.querydsl.core.util.BeanMap) BeanMap(com.querydsl.core.util.BeanMap) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with BeanMap

use of com.querydsl.core.util.BeanMap in project querydsl by querydsl.

the class PathBuilderTest method getByExample.

@SuppressWarnings("unchecked")
private <T> BooleanBuilder getByExample(T entity) {
    PathBuilder<T> entityPath = new PathBuilder<T>((Class<T>) entity.getClass(), "entity");
    BooleanBuilder conditions = new BooleanBuilder();
    Map<String, Object> beanMap = new BeanMap(entity);
    for (Map.Entry<String, Object> entry : beanMap.entrySet()) {
        if (!entry.getKey().equals("class")) {
            if (entry.getValue() != null) {
                conditions.and(entityPath.get(entry.getKey()).eq(entry.getValue()));
            }
        }
    }
    return conditions;
}
Also used : BeanMap(com.querydsl.core.util.BeanMap) BooleanBuilder(com.querydsl.core.BooleanBuilder) BeanMap(com.querydsl.core.util.BeanMap) Map(java.util.Map)

Aggregations

BeanMap (com.querydsl.core.util.BeanMap)2 Map (java.util.Map)2 BooleanBuilder (com.querydsl.core.BooleanBuilder)1 Path (com.querydsl.core.types.Path)1 HashMap (java.util.HashMap)1