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

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

import javax.inject.Inject;

import de.ivu.elect.business.email.entity.EmailVorgang;
import de.ivu.elect.jee.entity.ExtendedDAO;

@javax.enterprise.context.RequestScoped
public class EmailVorgangExtendedDAO extends AbstractEmailVorgangDAO 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: CountEmailLayoutNoFlush<br>
* Beschreibung: <br>
* EJBQL: select count(o) from EmailVorgang o where o.emailLayout=?1<br>
* SQL: <br>
*/
@Override
public java.lang.Long findByCountEmailLayout( @javax.annotation.Nonnull de.ivu.elect.business.email.entity.EmailLayout emailLayout) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("EmailVorgang.findByCountEmailLayout" ,  emailLayout  );

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

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

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

    return super.findByCountEmailLayout( emailLayout  );
}
/**
* Name: CountEmailVorlageNoFlush<br>
* Beschreibung: <br>
* EJBQL: select count(o) from EmailVorgang o where o.emailVorlage=?1<br>
* SQL: <br>
*/
@Override
public java.lang.Long findByCountEmailVorlage( @javax.annotation.Nonnull de.ivu.elect.business.email.entity.EmailVorlage emailVorlage) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("EmailVorgang.findByCountEmailVorlage" ,  emailVorlage  );

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

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

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

    return super.findByCountEmailVorlage( emailVorlage  );
}

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

    super.clear();
  }
}
