@Override public <E extends T> E refreshAll(E entity) { EntityProxy<E> proxy = context.proxyOf(entity, false); synchronized (proxy.syncObject()) { return context.read(proxy.type().getClassType()).refreshAll(entity, proxy); } }
@SuppressWarnings("unchecked") @Override public <E extends T> E refresh(E entity, Attribute<?, ?>... attributes) { EntityProxy<E> proxy = context.proxyOf(entity, false); synchronized (proxy.syncObject()) { return context .read(proxy.type().getClassType()) .refresh(entity, proxy, (Attribute<E, ?>[]) attributes); } }
@SuppressWarnings("unchecked") @Override public <E extends T> Iterable<E> refresh(Iterable<E> entities, Attribute<?, ?>... attributes) { Iterator<E> iterator = entities.iterator(); if (iterator.hasNext()) { E entity = iterator.next(); EntityProxy<E> proxy = context.proxyOf(entity, false); EntityReader<E, T> reader = context.read(proxy.type().getClassType()); return reader.batchRefresh(entities, (Attribute<E, ?>[]) attributes); } return entities; }
@Override public <E extends T> Selection<? extends Result<E>> select( Class<E> type, QueryAttribute<?, ?>... attributes) { checkClosed(); EntityReader<E, T> reader = context.read(type); Set<Expression<?>> selection; ResultReader<E> resultReader; if (attributes.length == 0) { selection = reader.defaultSelection(); resultReader = reader.newResultReader(reader.defaultSelectionAttributes()); } else { selection = new LinkedHashSet<>(Arrays.<Expression<?>>asList(attributes)); resultReader = reader.newResultReader(attributes); } SelectOperation<E> select = new SelectOperation<>(context, resultReader); QueryElement<? extends Result<E>> query = new QueryElement<>(SELECT, entityModel, select); return query.select(selection).from(type); }