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

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

import javax.inject.Inject;

import de.ivu.elect.business.person.entity.Beruf;
import de.ivu.elect.jee.entity.ExtendedDAO;

@javax.enterprise.context.RequestScoped
public class BerufExtendedDAO extends AbstractBerufDAO 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 obj FROM Beruf obj<br>
* SQL: <br>
*/
@Override
public java.util.List<Beruf> 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("Beruf.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<Beruf>) cache.lookup(key));
    }

    return super.findByAll( );
}
/**
* Name: CountNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT COUNT(obj) FROM Beruf obj<br>
* SQL: <br>
*/
@Override
public java.lang.Long findByCount() {

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

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

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

      return (java.lang.Long) cache.lookup(key);
    }

    return super.findByCount( );
}

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

    super.clear();
  }
}
