Examples of PostDaoImpl


Examples of sino.dao.jpa.PostDaoImpl

        ps.setString(6, "NEWS");
        ps.execute();
    }

    public void testA() throws Exception {
        PostDaoImpl postDao = new PostDaoImpl();
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("persistenceUnit");
        postDao.setEntityManager(factory.createEntityManager());
        postDao.getEntityManager().getTransaction().begin();
        Post post = new Post();
        post.setContent("内容");
        post.setTitle("标题");
        post.setPreview("预览");
        post.setModificationDate(new Date());
        post.setCreationDate(new Date());
        post.setType(PostType.NEWS);
        postDao.persist(post);
        postDao.getEntityManager().getTransaction().commit();
        postDao.setEntityManager(factory.createEntityManager());
        System.out.println(postDao.retrieve(post.getId()).getContent());
        System.out.println(postDao.retrieve(1).getPreview());
    }
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.