Search in sources :

Example 1 with Home

use of org.hibernate.test.annotations.id.sequences.entities.Home in project hibernate-orm by hibernate.

the class IdTest method testParameterizedAuto.

@Test
public void testParameterizedAuto() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Home h = new Home();
    s.persist(h);
    tx.commit();
    s.close();
    assertNotNull(h.getId());
    s = openSession();
    tx = s.beginTransaction();
    Home reloadedHome = (Home) s.get(Home.class, h.getId());
    assertEquals(h.getId(), reloadedHome.getId());
    s.delete(reloadedHome);
    tx.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) Home(org.hibernate.test.annotations.id.sequences.entities.Home) Session(org.hibernate.Session) Test(org.junit.Test)

Example 2 with Home

use of org.hibernate.test.annotations.id.sequences.entities.Home in project hibernate-orm by hibernate.

the class IdTest method testDefaultSequence.

@Test
public void testDefaultSequence() throws Exception {
    Session s;
    Transaction tx;
    s = openSession();
    tx = s.beginTransaction();
    Home h = new Home();
    s.persist(h);
    tx.commit();
    s.close();
    assertNotNull(h.getId());
    s = openSession();
    tx = s.beginTransaction();
    Home reloadedHome = (Home) s.get(Home.class, h.getId());
    assertEquals(h.getId(), reloadedHome.getId());
    s.delete(reloadedHome);
    tx.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) Home(org.hibernate.test.annotations.id.sequences.entities.Home) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

Session (org.hibernate.Session)2 Transaction (org.hibernate.Transaction)2 Home (org.hibernate.test.annotations.id.sequences.entities.Home)2 Test (org.junit.Test)2