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

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

import javax.inject.Inject;

import de.ivu.elect.business.konfiguration.entity.Konfiguration;
import de.ivu.elect.jee.entity.ExtendedDAO;

@javax.enterprise.context.RequestScoped
public class KonfigurationExtendedDAO extends AbstractKonfigurationDAO 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: AllNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT k FROM Konfiguration k<br>
* SQL: <br>
*/
@Override
public java.util.List<Konfiguration> findByAll() {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Konfiguration.findByAll"  );

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

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

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

    return super.findByAll( );
}
/**
* Name: MandantNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT OBJECT(o) FROM Konfiguration o WHERE o.mandant=?1<br>
* SQL: <br>
*/
@Override
public java.util.List<Konfiguration> findByMandant( @javax.annotation.Nonnull de.ivu.elect.business.mandant.entity.Mandant mandant) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Konfiguration.findByMandant" ,  mandant  );

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

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

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

    return super.findByMandant( mandant  );
}
/**
* Name: MandantSchluesselNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT k FROM Konfiguration k WHERE k.mandant=?1 AND k.schluessel = ?2<br>
* SQL: <br>
*/
@Override
public Konfiguration findByMandantSchluessel( @javax.annotation.Nonnull de.ivu.elect.business.mandant.entity.Mandant mandant,  @javax.annotation.Nonnull java.lang.String schluessel) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Konfiguration.findByMandantSchluessel" ,  mandant ,  schluessel  );

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

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

      return (Konfiguration) cache.lookup(key);
    }

    return super.findByMandantSchluessel( mandant ,  schluessel  );
}
/**
* Name: SystemSchluesselNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT k FROM Konfiguration k WHERE k.schluessel = ?1<br>
* SQL: <br>
*/
@Override
public Konfiguration findBySystemSchluessel( @javax.annotation.Nonnull java.lang.String schluessel) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("Konfiguration.findBySystemSchluessel" ,  schluessel  );

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

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

      return (Konfiguration) cache.lookup(key);
    }

    return super.findBySystemSchluessel( schluessel  );
}

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

    super.clear();
  }
}
