Search in sources :

Example 6 with Cat

use of org.hibernate.jpa.test.Cat in project hibernate-orm by hibernate.

the class CallbacksTest method testPostPersist.

@Test
public void testPostPersist() throws Exception {
    EntityManager em = getOrCreateEntityManager();
    Cat c = new Cat();
    em.getTransaction().begin();
    c.setLength(23);
    c.setAge(2);
    c.setName("Beetle");
    c.setDateOfBirth(new Date());
    em.persist(c);
    em.getTransaction().commit();
    em.close();
    List ids = Cat.getIdList();
    Object id = Cat.getIdList().get(ids.size() - 1);
    assertNotNull(id);
}
Also used : EntityManager(javax.persistence.EntityManager) Cat(org.hibernate.jpa.test.Cat) ArrayList(java.util.ArrayList) List(java.util.List) Date(java.util.Date) Test(org.junit.Test)

Aggregations

Date (java.util.Date)6 EntityManager (javax.persistence.EntityManager)6 Cat (org.hibernate.jpa.test.Cat)6 Test (org.junit.Test)6 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutput (java.io.ObjectOutput)2 ObjectOutputStream (java.io.ObjectOutputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 HibernateEntityManager (org.hibernate.jpa.HibernateEntityManager)2 Item (org.hibernate.jpa.test.Item)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 Kitten (org.hibernate.jpa.test.Kitten)1 FailureExpected (org.hibernate.testing.FailureExpected)1