/*
 * JPA DAO Template
 *
 *
 * Takatuka - Template fuer JPA DAO (Extended = ExtendedPersistenceContext ConversationScope (Group = EntityExtendedDAO.class)
 *
 */

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

import javax.inject.Inject;

import de.ivu.elect.business.kandidatur.entity.Listenkandidatur;
import de.ivu.elect.jee.entity.ExtendedDAO;

@javax.enterprise.context.RequestScoped
public class ListenkandidaturExtendedDAO extends AbstractListenkandidaturDAO implements java.io.Serializable {

  private static final long serialVersionUID = 1L;

  @Inject
  transient ExtendedDAO extendedDAO;

  @Inject
  transient de.ivu.elect.presentation.system.ExtendedDAORequestCache cache;

  @Override
  protected javax.persistence.EntityManager getEntityManager() {
    return extendedDAO.getEntityManager();
  }

  @Override
  public void flush() {
    extendedDAO.flush();
  }

  public void flushNewTransaction() {
    extendedDAO.flushNewTransaction();
  }

/**
* Name: GebietNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT Object(o) FROM Listenkandidatur o WHERE o.liste.gruppeImGebiet.gebiet=?1<br>
* SQL: <br>
*/
@Override
public java.util.List<Listenkandidatur> findByGebiet( @javax.annotation.Nonnull de.ivu.elect.business.gebietsbaum.entity.Gebiet gebiet) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Listenkandidatur.findByGebiet" ,  gebiet  );

      if (!cache.contains(key)) {
        if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
          System.out.println("Query: " + getClass().getName() + ".findByGebiet(): Miss");
        }

        cache.put(key, super.findByGebiet( gebiet  ));
      } else if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
        System.out.println("Query: " + getClass().getName() + ".findByGebiet(): Hit");
      }

      return new java.util.ArrayList<>((java.util.List<Listenkandidatur>) cache.lookup(key));
    }

    return super.findByGebiet( gebiet  );
}
/**
* Name: GruppeNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT o FROM Listenkandidatur o WHERE o.liste.gruppeImGebiet.gruppe = ?1<br>
* SQL: <br>
*/
@Override
public java.util.List<Listenkandidatur> findByGruppe( @javax.annotation.Nonnull de.ivu.elect.business.gruppe.entity.Gruppe gruppe) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Listenkandidatur.findByGruppe" ,  gruppe  );

      if (!cache.contains(key)) {
        if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
          System.out.println("Query: " + getClass().getName() + ".findByGruppe(): Miss");
        }

        cache.put(key, super.findByGruppe( gruppe  ));
      } else if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
        System.out.println("Query: " + getClass().getName() + ".findByGruppe(): Hit");
      }

      return new java.util.ArrayList<>((java.util.List<Listenkandidatur>) cache.lookup(key));
    }

    return super.findByGruppe( gruppe  );
}
/**
* Name: ListeOrderByRelativePositionNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT obj FROM Listenkandidatur obj where obj.liste = ?1 ORDER BY obj.relativePosition<br>
* SQL: <br>
*/
@Override
public java.util.List<Listenkandidatur> findByListeOrderByRelativePosition( @javax.annotation.Nonnull de.ivu.elect.business.wahlvorschlag.entity.Liste liste) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Listenkandidatur.findByListeOrderByRelativePosition" ,  liste  );

      if (!cache.contains(key)) {
        if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
          System.out.println("Query: " + getClass().getName() + ".findByListeOrderByRelativePosition(): Miss");
        }

        cache.put(key, super.findByListeOrderByRelativePosition( liste  ));
      } else if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
        System.out.println("Query: " + getClass().getName() + ".findByListeOrderByRelativePosition(): Hit");
      }

      return new java.util.ArrayList<>((java.util.List<Listenkandidatur>) cache.lookup(key));
    }

    return super.findByListeOrderByRelativePosition( liste  );
}
/**
* Name: WahlNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT o FROM Listenkandidatur o WHERE o.wahl=?1<br>
* SQL: <br>
*/
@Override
public java.util.List<Listenkandidatur> findByWahl( @javax.annotation.Nonnull de.ivu.elect.business.wahl.entity.Wahl wahl) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Listenkandidatur.findByWahl" ,  wahl  );

      if (!cache.contains(key)) {
        if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
          System.out.println("Query: " + getClass().getName() + ".findByWahl(): Miss");
        }

        cache.put(key, super.findByWahl( wahl  ));
      } else if (de.ivu.elect.business.system.control.LogQueries.LOG_QUERIES) {
        System.out.println("Query: " + getClass().getName() + ".findByWahl(): Hit");
      }

      return new java.util.ArrayList<>((java.util.List<Listenkandidatur>) cache.lookup(key));
    }

    return super.findByWahl( wahl  );
}

  @Override
  public void clear() {
    cache.clear();

    super.clear();
  }
}
