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

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

import javax.inject.Inject;

import de.ivu.elect.business.ui.entity.UITableColumnOrder;
import de.ivu.elect.jee.entity.ExtendedDAO;

@javax.enterprise.context.RequestScoped
public class UITableColumnOrderExtendedDAO extends AbstractUITableColumnOrderDAO 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: BenutzerKeyAndColumnBuilderKeyNoFlush<br>
* Beschreibung: <br>
* EJBQL: SELECT o FROM UITableColumnOrder o WHERE o.columnBuilderKey = ?2 AND o.benutzerKey=?1<br>
* SQL: <br>
*/
@Override
public java.util.List<UITableColumnOrder> findByBenutzerKeyAndColumnBuilderKey( @javax.annotation.Nonnull String benutzerKey,  @javax.annotation.Nonnull String columnBuilderKey) {

    if (de.ivu.elect.business.system.control.CacheQueries.CACHE_QUERIES) {
      de.ivu.elect.presentation.system.FinderKey key = new de.ivu.elect.presentation.system.FinderKey("UITableColumnOrder.findByBenutzerKeyAndColumnBuilderKey" ,  benutzerKey ,  columnBuilderKey  );

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

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

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

    return super.findByBenutzerKeyAndColumnBuilderKey( benutzerKey ,  columnBuilderKey  );
}

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

    super.clear();
  }
}
