Package javax.persistence

Examples of javax.persistence.EntityManager


    }

    @Factory(value = "wikiStart", scope = ScopeType.CONVERSATION, autoCreate = true)
    public WikiDocument loadWikiStart() {
        log.debug("loading wiki start into current conversation");
        EntityManager em = (EntityManager)Component.getInstance("restrictedEntityManager");
        try {
            return (WikiDocument) em
                    .createQuery("select d from WikiDocument d where d.id = :id")
                    .setParameter("id", Preferences.instance().get(WikiPreferences.class).getDefaultDocumentId())
                    .setHint("org.hibernate.comment", "Loading wikiStart")
                    .setHint("org.hibernate.cacheable", false)
                    .getSingleResult();
View Full Code Here


    // Loads the same instance into a different persistence context
    @Factory(value = "restrictedWikiRoot", scope = ScopeType.PAGE, autoCreate = true)
    public WikiDirectory loadWikiRootRestricted() {
        log.debug("loading wiki root into restricted PC");
        EntityManager em = (EntityManager)Component.getInstance("restrictedEntityManager");
        WikiDirectory wikiroot = (WikiDirectory) Component.getInstance("wikiRoot");
        try {
            return (WikiDirectory) em
                    .createQuery("select d from WikiDirectory d left join fetch d.feed where d.id = :id")
                    .setParameter("id", wikiroot.getId())
                    .setHint("org.hibernate.comment", "Loading wikiRootRestricted")
                    .setHint("org.hibernate.cacheable", false)
                    .getSingleResult();
View Full Code Here

    }

    @Factory(value = "memberArea", scope = ScopeType.PAGE, autoCreate = true)
    public WikiDirectory loadMemberArea() {
        log.debug("loading member area");
        EntityManager em = (EntityManager)Component.getInstance("entityManager");
        String memberAreaName = Preferences.instance().get(WikiPreferences.class).getMemberArea();
        try {
            return (WikiDirectory) em
                    .createQuery("select d from WikiDirectory d left join fetch d.feed where d.wikiname = :name and d.parent.parent is null")
                    .setParameter("name", WikiUtil.convertToWikiName(memberAreaName) )
                    .setHint("org.hibernate.comment", "Loading memberArea")
                    .setHint("org.hibernate.cacheable", false)
                    .getSingleResult();
View Full Code Here

    }

    @Factory(value = "trashArea", scope = ScopeType.PAGE, autoCreate = true)
    public WikiDirectory loadTrashArea() {
        log.debug("loading trash area");
        EntityManager em = (EntityManager)Component.getInstance("entityManager");
        String trashAreaName = Preferences.instance().get(WikiPreferences.class).getTrashArea();
        try {
            return (WikiDirectory) em
                    .createQuery("select d from WikiDirectory d left join fetch d.feed where d.wikiname = :name and d.parent.parent is null")
                    .setParameter("name", WikiUtil.convertToWikiName(trashAreaName) )
                    .setHint("org.hibernate.comment", "Loading trashArea")
                    .setHint("org.hibernate.cacheable", false)
                    .getSingleResult();
View Full Code Here

        }.run();

        new FacesRequest() {

            protected void invokeApplication() throws Exception {
                EntityManager em = (EntityManager) getInstance("restrictedEntityManager");

                WikiDocument d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 7l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 1;
                em.clear();

                d = (WikiDocument)
                        em.createQuery("select d from WikiDocument d left join fetch d.incomingLinks where d.id = :id")
                                .setParameter("id", 8l)
                                .getSingleResult();
                assert d.getIncomingLinks().size() == 2;
                em.clear();

                WikiUpload f = (WikiUpload)
                        em.createQuery("select f from WikiUpload f left join fetch f.incomingLinks where f.id = :id")
                                .setParameter("id", 30l)
                                .getSingleResult();
                assert f.getIncomingLinks().size() == 1;
            }
        }.run();
View Full Code Here

    @Test
    public void documentURL() throws Exception {
        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

         InitialContext ctx = new InitialContext();
        
         t = (UserTransaction) ctx.lookup("UserTransaction");
         t.begin();
     
         EntityManager em = (EntityManager) Component.getInstance("entityManager", true);
        
         List<Auction> auctions = em.createQuery("from Auction").getResultList();
        
         Calendar cal = new GregorianCalendar();
        
         Random r = new Random(System.currentTimeMillis());
        
         for (Auction auction : auctions)
         {
            cal.setTime(auction.getEndDate());
            cal.add(Calendar.DATE, r.nextInt(7));
            cal.add(Calendar.MINUTE, 30 + r.nextInt(1410));
            auction.setEndDate(cal.getTime());
            em.merge(auction);
           
            AuctionEndAction auctionEnd = (AuctionEndAction) Component.getInstance(AuctionEndAction.class, true);
            auctionEnd.endAuction(auction.getAuctionId(), auction.getEndDate());
         }
        
View Full Code Here

{
  
   public Object getAsObject(FacesContext context, UIComponent component, String value)
   {
     
      EntityManager entityManager = (EntityManager) Component.getInstance("entityManager");
     
      if (value != null)
      {
         try
         {
            Integer id = Integer.parseInt(value);
            if (id != null)
            {
               return entityManager.find(Film.class, id);
            }
         }
         catch (NumberFormatException e)
         {
         }
View Full Code Here

    }

    @Factory(value = "helpArea", scope = ScopeType.PAGE, autoCreate = true)
    public WikiDirectory loadHelpArea() {
        log.debug("loading help area");
        EntityManager em = (EntityManager)Component.getInstance("entityManager");
        String helpAreaName = Preferences.instance().get(WikiPreferences.class).getHelpArea();
        try {
            return (WikiDirectory) em
                    .createQuery("select d from WikiDirectory d left join fetch d.feed where d.wikiname = :name and d.parent.parent is null")
                    .setParameter("name", WikiUtil.convertToWikiName(helpAreaName) )
                    .setHint("org.hibernate.comment", "Loading trashArea")
                    .setHint("org.hibernate.cacheable", false)
                    .getSingleResult();
View Full Code Here

    }

    @Factory(value = "linkProtocolMap", scope = ScopeType.CONVERSATION, autoCreate = true)
    public Map<String, LinkProtocol> loadLinkProtocols() {
        log.debug("loading link protocol map");
        EntityManager em = (EntityManager)Component.getInstance("entityManager");
        Map<String, LinkProtocol> linkProtocols = new TreeMap<String, LinkProtocol>();
        //noinspection unchecked
        List<Object[]> result = em
                .createQuery("select lp.prefix, lp from LinkProtocol lp order by lp.prefix asc")
                .setHint("org.hibernate.comment", "Loading link protocols")
                .setHint("org.hibernate.cacheable", true)
                .getResultList();
        for (Object[] objects : result) {
View Full Code Here

TOP

Related Classes of javax.persistence.EntityManager

Copyright © 2018 www.massapicom. 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.