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());
}