/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */
package org.jboss.ejb3.test.regressionHHH275;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.PersistenceContext;

/**
 * comment
 *
 * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
 */
@Stateless
@Remote(SearchDAORemote.class)
public class SearchDAO implements SearchDAORemote
{

   @PersistenceContext private EntityManager em;

   public void create()
   {
      {
         SavedSearch s1 = new SavedSearch();
         s1.setId("USER_ALL_USERS");
         s1.setSearchTitle("TITLE");
         em.persist(s1);
      }

      {
         SavedSearch s1 = new SavedSearch();
         s1.setId("u1");
         s1.setSearchTitle("TITLE");
         em.persist(s1);
      }

   }

   public int find()
   {
      Query q = em.createQuery("From SavedSearch s WHERE (s.id = 'u1' OR s.id = 'USER_ALL_USERS') AND s.searchTitle = 'CRAP'");
      return q.getResultList().size();
   }
}
