public void test() { // test readAll getSession().readAllObjects(Employee.class); getSession().getIdentityMapAccessor().initializeIdentityMap(Employee.class); // test readObject Employee employee = (Employee) getSession().readObject(Employee.class, new ExpressionBuilder().get("id").equal(99)); // test delete with an employee read from the database employee = (Employee) getSession().readObject(Employee.class); try { getAbstractSession().deleteObject(employee); } catch (DatabaseException exc) { // if we get an integrity exception here, the query went to the DB and was not redirected redirectedDeleteObject = false; } UnitOfWork uow = getSession().acquireUnitOfWork(); // test update with an employee read from the database employee = (Employee) uow.readObject(Employee.class); employee.setFirstName(employee.getFirstName() + "-changed"); // insert an employee to test the insert behavior employee = new Employee(); employee.setFirstName("Paul"); employee.setLastName("Sheldon"); uow.registerObject(employee); uow.commit(); }
protected void test() { // Read in a Country. aCountry = (Country) uow.readObject(Country.class); oldName = aCountry.getName(); // Update the country and commit. Nothing should be written to the db. uow.registerObject(aCountry); aCountry.setName(aCountry.getName() + " 22"); uow.commit(); }
public void test() { UnitOfWork uow = getSession().acquireUnitOfWork(); Employee_XML emp = (Employee_XML) uow.readObject( Employee_XML.class, new ExpressionBuilder().get("firstName").equal("Frank")); Document resume = emp.resume; // System.out.println(resume); NodeList nodes = resume.getElementsByTagName("last-name"); // System.out.println(nodes); Node lastName = nodes.item(0); Node lastNameText = lastName.getFirstChild(); lastNameText.setNodeValue("Williams"); emp.payroll_xml = "<payroll><salary>50000</salary><pay-period>weekly</pay-period></payroll>"; uow.commit(); }