Session s = openSession();
Transaction t = s.beginTransaction();
Organization ifa = new Organization("IFA");
Organization jboss = new Organization("JBoss");
Person gavin = new Person("Gavin");
Employment emp = new Employment(gavin, jboss, "AU");
Serializable orgId = s.save(jboss);
Serializable orgId2 = s.save(ifa);
s.save(gavin);
s.save(emp);
t.commit();
s.close();
s = openSession();
t = s.beginTransaction();
List list = s.createSQLQuery( getEmploymentSQL() )
.addEntity( Employment.class.getName() )
.list();
assertEquals( 1,list.size() );
Employment emp2 = (Employment) list.get(0);
assertEquals(emp2.getEmploymentId(), emp.getEmploymentId() );
assertEquals(emp2.getStartDate().getDate(), emp.getStartDate().getDate() );
assertEquals(emp2.getEndDate(), emp.getEndDate() );
s.clear();
list = s.createSQLQuery( getEmploymentSQL() )
.addEntity( Employment.class.getName() )