All Downloads are FREE. Search and download functionalities are using the official Maven repository.

arp.repository.SimplePersistenceRepository Maven / Gradle / Ivy

The newest version!
package arp.repository;

import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

public abstract class SimplePersistenceRepository extends
		PersistenceRepository {

	@Override
	protected E findByIdForUpdateImpl(I id) {
		return findByIdImpl(id);
	}

	@Override
	protected E saveIfAbsentImpl(I id, E entity) {
		E existsEntity = findByIdImpl(id);
		if (existsEntity == null) {
			saveImpl(id, entity);
		}
		return existsEntity;
	}

	@Override
	protected void updateBatchImpl(Map entitiesToUpdate) {
		for (Entry entry : entitiesToUpdate.entrySet()) {
			updateImpl(entry.getKey(), entry.getValue());
		}
	}

	@Override
	protected void saveBatchImpl(Map entities) {
		for (Entry entry : entities.entrySet()) {
			saveImpl(entry.getKey(), entry.getValue());
		}
	}

	@Override
	protected void removeBatchImpl(Set ids) {
		for (I id : ids) {
			removeImpl(id);
		}
	}

	@Override
	protected void unlockBatchImpl(Set ids) {
	}

	@Override
	protected void unlockImpl(I id) {
	}

}