use of org.hibernate.Transaction in project hibernate-orm by hibernate.
the class IdTest method testIdInEmbeddableSuperclass.
@Test
public void testIdInEmbeddableSuperclass() throws Exception {
Session s;
Transaction tx;
s = openSession();
tx = s.beginTransaction();
FirTree chrismasTree = new FirTree();
s.persist(chrismasTree);
tx.commit();
s.clear();
tx = s.beginTransaction();
chrismasTree = (FirTree) s.get(FirTree.class, chrismasTree.getId());
assertNotNull(chrismasTree);
s.delete(chrismasTree);
tx.commit();
s.close();
}
use of org.hibernate.Transaction 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();
}
use of org.hibernate.Transaction 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();
}
use of org.hibernate.Transaction in project hibernate-orm by hibernate.
the class IdTest method testMethodLevelGenerator.
@Test
public void testMethodLevelGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Department b = new Department();
s.persist(b);
tx.commit();
s.close();
assertNotNull(b.getId());
s = openSession();
tx = s.beginTransaction();
s.delete(s.get(Department.class, b.getId()));
tx.commit();
s.close();
}
use of org.hibernate.Transaction in project hibernate-orm by hibernate.
the class IdTest method testClassLevelGenerator.
@Test
public void testClassLevelGenerator() throws Exception {
Session s = openSession();
Transaction tx = s.beginTransaction();
Store b = new Store();
s.persist(b);
tx.commit();
s.close();
assertNotNull(b.getId());
s = openSession();
tx = s.beginTransaction();
s.delete(s.get(Store.class, b.getId()));
tx.commit();
s.close();
}
Aggregations