// Path: src/main/java/de/dhbw/humbuch/event/EntityUpdateEvent.java
// public class EntityUpdateEvent {
// 	public final List<Class<? extends Entity>> updatedEntityTypes;
// 
// 	/**
// 	 * Create a new {@link EntityUpdateEvent} with a list of updated
// 	 * {@link Entity} types
// 	 * 
// 	 * @param updatedEntityTypes
// 	 *            types of the {@link Entity}s which were updated
// 	 */
// 	@SafeVarargs
// 	public EntityUpdateEvent(Class<? extends Entity>... updatedEntityTypes) {
// 		this.updatedEntityTypes = new ArrayList<>(
// 				Arrays.asList(updatedEntityTypes));
// 	}
// 
// 	/**
// 	 * Check if the {@link EntityUpdateEvent} contains a certain {@link Entity}
// 	 * class which was updated
// 	 * 
// 	 * @param entityType
// 	 *            type of the {@link Entity} to be checked
// 	 * @return <code>true</code> if event contains the {@link Entity} type,
// 	 *         otherwise <code>false</code>
// 	 */
// 	public boolean contains(Class<? extends Entity> entityType) {
// 		return updatedEntityTypes.contains(entityType);
// 	}
// }
// 
// Path: src/main/java/de/dhbw/humbuch/model/entity/Entity.java
// public interface Entity {
// 
// }


import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.TypeLiteral;
import com.google.inject.persist.Transactional;
import de.dhbw.humbuch.event.EntityUpdateEvent;
import de.dhbw.humbuch.model.entity.Entity;
	@Override
	@Transactional
	public void delete(Collection<EntityType> entities) {
		delete(entities, FireUpdateEvent.NO);
	}

	@Override
	@Transactional
	public void delete(Collection<EntityType> entities, FireUpdateEvent fireUpdateEvent) {
		getEntityManager().clear();
		for (EntityType entity : entities) {
			getEntityManager().remove(getEntityManager().merge(entity));
		}
		if(fireUpdateEvent == FireUpdateEvent.YES) {
			fireUpdateEvent();
		}
	}

	@Override
	public EntityManager getEntityManager() {
		return emProvider.get();
	}
	
	@Override
	public Class<EntityType> getEntityClass() {
		return entityClass;
	}

	@Override
	public void fireUpdateEvent() {
// Path: src/main/java/de/dhbw/humbuch/event/EntityUpdateEvent.java
// public class EntityUpdateEvent {
// 	public final List<Class<? extends Entity>> updatedEntityTypes;
// 
// 	/**
// 	 * Create a new {@link EntityUpdateEvent} with a list of updated
// 	 * {@link Entity} types
// 	 * 
// 	 * @param updatedEntityTypes
// 	 *            types of the {@link Entity}s which were updated
// 	 */
// 	@SafeVarargs
// 	public EntityUpdateEvent(Class<? extends Entity>... updatedEntityTypes) {
// 		this.updatedEntityTypes = new ArrayList<>(
// 				Arrays.asList(updatedEntityTypes));
// 	}
// 
// 	/**
// 	 * Check if the {@link EntityUpdateEvent} contains a certain {@link Entity}
// 	 * class which was updated
// 	 * 
// 	 * @param entityType
// 	 *            type of the {@link Entity} to be checked
// 	 * @return <code>true</code> if event contains the {@link Entity} type,
// 	 *         otherwise <code>false</code>
// 	 */
// 	public boolean contains(Class<? extends Entity> entityType) {
// 		return updatedEntityTypes.contains(entityType);
// 	}
// }
// 
// Path: src/main/java/de/dhbw/humbuch/model/entity/Entity.java
// public interface Entity {
// 
// }


// Path: src/main/java/de/dhbw/humbuch/model/DAOImpl.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.persistence.EntityManager;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Order;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.TypeLiteral;
import com.google.inject.persist.Transactional;
import de.dhbw.humbuch.event.EntityUpdateEvent;
import de.dhbw.humbuch.model.entity.Entity;

	@Override
	@Transactional
	public void delete(Collection<EntityType> entities) {
		delete(entities, FireUpdateEvent.NO);
	}

	@Override
	@Transactional
	public void delete(Collection<EntityType> entities, FireUpdateEvent fireUpdateEvent) {
		getEntityManager().clear();
		for (EntityType entity : entities) {
			getEntityManager().remove(getEntityManager().merge(entity));
		}
		if(fireUpdateEvent == FireUpdateEvent.YES) {
			fireUpdateEvent();
		}
	}

	@Override
	public EntityManager getEntityManager() {
		return emProvider.get();
	}
	
	@Override
	public Class<EntityType> getEntityClass() {
		return entityClass;
	}

	@Override
	public void fireUpdateEvent() {
		eventBus.post(new EntityUpdateEvent(getEntityClass()));