Package javax.persistence

Examples of javax.persistence.EntityManager.createQuery()


    if (named == null)
      return em.find(getMethodReturnType(), parameters[0]);
    else {
      String ejbql = "from " + getMethodReturnType().getSimpleName() + " entity where entity." + named.value()
              + "=?";
      Query query = em.createQuery(ejbql);
      query.setParameter(1, parameters[0]);
      return query.getSingleResult();
    }
  }
 
View Full Code Here


      if (retrieve.resultClass().equals(void.class))
        return em.createNativeQuery(retrieve.query());
      else
        return em.createNativeQuery(retrieve.query(), retrieve.resultClass());
    } else
      return em.createQuery(retrieve.query());
  }
 
  @Override
  protected void initialize() {
    annotationClass = Retrieve.class;
View Full Code Here

      if (find.resultClass().equals(void.class))
        return em.createNativeQuery(find.query());
      else
        return em.createNativeQuery(find.query(), find.resultClass());
    } else
      return em.createQuery(find.query());
  }
 
  @Override
  protected void initialize() {
    annotationClass = Find.class;
View Full Code Here

     * @return the list of results.
     */
    public List findLifecycleEventByEntity(final String className, final CallbackType callbackEvent,
            final int entityId) {
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createQuery("SELECT e FROM ListenerManager "
                + "e WHERE e.className = :className AND e.callbackEvent= :event AND e.entityId = :entityId");
        query.setParameter("className", className);
        query.setParameter("event", callbackEvent);
        query.setParameter("entityId", new Integer(entityId));
        return query.getResultList();
View Full Code Here

        // Checks if the size of descriptions is the same as eventClassNames.
        assertTrue(descriptions.length == eventClassNames.length,
                "The length of descriptions and event class names must be equal.");

        EntityManager entityManager = entityManagerFactory.createEntityManager();
        Query query = entityManager.createQuery("SELECT e FROM OperationLogger "
                + "e WHERE e.className = :className AND e.callbackEvent= :event AND e.operationType = :operationType");
        query.setParameter("className", className);
        query.setParameter("event", event);
        query.setParameter("operationType", operationType);
        List callbackList = query.getResultList();
View Full Code Here

         t = (UserTransaction) ctx.lookup("UserTransaction");
         t.begin();
     
         EntityManager em = (EntityManager) Component.getInstance("entityManager", true);
        
         List<Auction> auctions = em.createQuery("select a from Auction a").getResultList();
        
         Calendar cal = new GregorianCalendar();
        
         Random r = new Random(System.currentTimeMillis());
        
View Full Code Here

        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d where d.id = :id")
                                .setParameter("id", 6l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("6.lace");
                assert d.getWikiURL().equals("CCC/One");
View Full Code Here

        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");
                WikiDirectory d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 3l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("3.lace");
                assert d.getWikiURL().equals("CCC");
View Full Code Here

                assert d.getPermURL(".lace").equals("3.lace");
                assert d.getWikiURL().equals("CCC");

                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 4l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("4.lace");
                assert d.getWikiURL().equals("CCC/DDD");
View Full Code Here

                assert d.getPermURL(".lace").equals("4.lace");
                assert d.getWikiURL().equals("CCC/DDD");

                d = (WikiDirectory)
                        em.createQuery("select d from WikiDirectory d where d.id = :id")
                                .setParameter("id", 1l)
                                .getSingleResult();

                assert d.getPermURL(".lace").equals("1.lace");
                assert d.getWikiURL().equals("");
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.