Package auction.dao.ejb3

Examples of auction.dao.ejb3.ItemDAOBean


        // Start a unit of work (manually, no container)
        getUserTransaction().begin();
        EntityManager em = getEntityManagerFactory().createEntityManager();

        // Prepare the DAOs (manually, no Seam)
        ItemDAO itemDAO = new ItemDAOBean();
        ((GenericEJB3DAO) itemDAO).setEntityManager(em);

        UserDAO userDAO = new UserDAOBean();
        ((GenericEJB3DAO) userDAO).setEntityManager(em);

        // Prepare a user object
        User user = userDAO.findById(1l, false);

        // Make a new auction item persistent
        Calendar startDate = GregorianCalendar.getInstance();
        Calendar endDate = GregorianCalendar.getInstance();
        endDate.add(Calendar.DAY_OF_YEAR, 3);

        MonetaryAmount initialPrice =
            new MonetaryAmount(new BigDecimal(123), Currency.getInstance("USD"));
        MonetaryAmount reservePrice =
            new MonetaryAmount(new BigDecimal(333), Currency.getInstance("USD"));

        Item newItem =
            new Item( "Testitem", "Test Description", user,
                      initialPrice, reservePrice,
                      startDate.getTime(), endDate.getTime() );

        // Don't forget to take the return value, this is basically a merge()
        newItem = itemDAO.makePersistent(newItem);

        // End the unit of work
        getUserTransaction().commit();
        em.close();
View Full Code Here


        // Prepare the DAOs (manually, no Seam)
        ItemDAO itemDAO = new ItemDAOBean();
        ((GenericEJB3DAO) itemDAO).setEntityManager(em);

        UserDAO userDAO = new UserDAOBean();
        ((GenericEJB3DAO) userDAO).setEntityManager(em);

        // Prepare a user object
        User user = userDAO.findById(1l, false);

        // Make a new auction item persistent
        Calendar startDate = GregorianCalendar.getInstance();
        Calendar endDate = GregorianCalendar.getInstance();
        endDate.add(Calendar.DAY_OF_YEAR, 3);
View Full Code Here

TOP

Related Classes of auction.dao.ejb3.ItemDAOBean

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.