JPA常见API

来源:互联网 发布:world of goo for mac 编辑:程序博客网 时间:2024/04/29 10:08
/** * 类似于 hibernate的persist(Object entity)方法,若对象有 id, 则不能执行 insert 操作, 而会抛出异常。 */@Testpublic void testJPAPersist() {Customer customer = new Customer();customer.setName("zhangsan");// 异常:customer.setId(100);entityManager.persist(customer);System.out.println(customer.getId());}

0 0
原创粉丝点击