Search in sources :

Example 1 with Furniture

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

the class IdTest method testGenericGenerator.

@Test
public void testGenericGenerator() throws Exception {
    Session s = openSession();
    Transaction tx = s.beginTransaction();
    SoundSystem system = new SoundSystem();
    system.setBrand("Genelec");
    system.setModel("T234");
    Furniture fur = new Furniture();
    s.persist(system);
    s.persist(fur);
    tx.commit();
    s.close();
    s = openSession();
    tx = s.beginTransaction();
    system = (SoundSystem) s.get(SoundSystem.class, system.getId());
    fur = (Furniture) s.get(Furniture.class, fur.getId());
    assertNotNull(system);
    assertNotNull(fur);
    s.delete(system);
    s.delete(fur);
    tx.commit();
    s.close();
}
Also used : Transaction(org.hibernate.Transaction) SoundSystem(org.hibernate.test.annotations.id.sequences.entities.SoundSystem) Furniture(org.hibernate.test.annotations.id.sequences.entities.Furniture) Session(org.hibernate.Session) Test(org.junit.Test)

Aggregations

Session (org.hibernate.Session)1 Transaction (org.hibernate.Transaction)1 Furniture (org.hibernate.test.annotations.id.sequences.entities.Furniture)1 SoundSystem (org.hibernate.test.annotations.id.sequences.entities.SoundSystem)1 Test (org.junit.Test)1