/*
 * JPA DAO Template
 *
 *
 * Takatuka - Template fuer JPA DAO
 *
 */

package de.ivu.elect.business.ergebnis.boundary;

import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
import javax.persistence.EntityNotFoundException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import de.ivu.elect.business.ergebnis.entity.DHondtQuotientListenInGruppe;
import de.ivu.elect.business.ergebnis.entity.DHondtQuotientListenInGruppeUK;

public abstract class AbstractDHondtQuotientListenInGruppeDAO extends de.ivu.elect.jee.entity.AbstractDAO<DHondtQuotientListenInGruppe,
      de.ivu.elect.business.ergebnis.entity.DHondtQuotientPK
  , DHondtQuotientListenInGruppeUK> {

  private static final long serialVersionUID = 1L;

  private static final Logger LOG = LoggerFactory.getLogger(AbstractDHondtQuotientListenInGruppeDAO.class);

  public AbstractDHondtQuotientListenInGruppeDAO() {
    super();
  }

  public boolean isEntityWithPKPresent(
            de.ivu.elect.business.ergebnis.entity.DHondtQuotientPK
     pk) {
    if (pk != null && pk.getId() != null) {
      return findByPrimaryKey(pk) != null;
    }

    return false;
  }

  @Override
  public DHondtQuotientListenInGruppe findByPrimaryKey(
      de.ivu.elect.business.ergebnis.entity.DHondtQuotientPK
    pk) {
    if (pk != null && pk.getId() != null) {
      return findByPrimaryKey(pk.getId());
    }

    throw new IllegalArgumentException("PK oder PK.getId() ist null! [pk = " + pk + "]");
  }


  @Override
  protected DHondtQuotientListenInGruppe findByPrimaryKey(Long id) {
    if (id == null) {
      throw new IllegalArgumentException("ID ist null! [id = " + id + "]");
    }
  return getEntityManager().find(DHondtQuotientListenInGruppe.class, id, CACHE_PROPERTIES);
  }





  @Override
  public boolean isEntityWithUKPresent(de.ivu.elect.business.ergebnis.entity.DHondtQuotientListenInGruppeUK uk) {
    try {
      return findByUK(uk) != null;
    } catch (javax.persistence.NoResultException nre) {
      return false;
    }
  }

  @Override
  public boolean isEntityWithUKHasPK(de.ivu.elect.business.ergebnis.entity.DHondtQuotientListenInGruppeUK uk,
      de.ivu.elect.business.ergebnis.entity.DHondtQuotientPK
    pk

  ) {
    try {
      return findByUK(uk).getPk().equals(pk);
    } catch (NoResultException ignored) {
      // Do nothing - be happy.
    }
    return true;
  }

    public de.ivu.elect.business.ergebnis.entity.DHondtQuotientListenInGruppe findByUK(de.ivu.elect.business.ergebnis.entity.DHondtQuotientListenInGruppeUK uk){
        throw new UnsupportedOperationException("Kein UK definiert");
    }


}