Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Entity
- public class Foo {
- @Id
- private Long id;
- private String name;
- // <init>s and getters and setters
- public class EntityTests
- private String name;
- @Test
- public void test2() throws Exception {
- EntityManager entityManager = entityManagerFactory.createEntityManager();
- entityManager.getTransaction().begin();
- Foo foo=new Foo(1l,"bar");
- entityManager.persist(foo);
- entityManager.getTransaction().commit();
- entityManager.close();
- entityManager = entityManagerFactory.createEntityManager();
- entityManager.getTransaction().begin();
- Foo foo2=new Foo(1l,"baz");
- entityManager.persist(foo2);
- entityManager.getTransaction().commit();
- entityManager.close();
- }
- sql> select*from foo;
- ID | NAME
- 1 | bar
- 1 | baz
Add Comment
Please, Sign In to add comment