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

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

import javax.inject.Inject;

import de.ivu.elect.business.system.entity.SystemLog;
import de.ivu.elect.jee.entity.ExtendedDAO;

@javax.enterprise.context.RequestScoped
public class SystemLogExtendedDAO extends AbstractSystemLogDAO 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: CountStatusArtNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT COUNT(o) FROM SystemLog o WHERE o.mandant=?1 AND o.status = ?2 AND o.logNachrichtArt=?3<br>
* SQL: <br>
*/
@Override
public java.lang.Long findByCountStatusArt( @javax.annotation.Nonnull de.ivu.elect.business.mandant.entity.Mandant mandant,  @javax.annotation.Nonnull de.ivu.elect.business.system.entity.SystemLogStatus status,  @javax.annotation.Nonnull de.ivu.elect.business.system.entity.LogNachrichtArt art) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("SystemLog.findByCountStatusArt" ,  mandant ,  status ,  art  );

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

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

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

    return super.findByCountStatusArt( mandant ,  status ,  art  );
}
/**
* Name: CountStatusNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT COUNT(o) FROM SystemLog o WHERE o.mandant=?1 AND o.status = ?2<br>
* SQL: <br>
*/
@Override
public java.lang.Long findByCountStatus( @javax.annotation.Nonnull de.ivu.elect.business.mandant.entity.Mandant mandant,  @javax.annotation.Nonnull de.ivu.elect.business.system.entity.SystemLogStatus status) {

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

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

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

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

    return super.findByCountStatus( mandant ,  status  );
}

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

    super.clear();
  }
}
