use of org.jaffa.persistence.domainobjects.PartAdditional in project jaffa-framework by jaffa-projects.
the class CharFieldTest method testDelete.
/**
* Deletes a new record.
*/
public void testDelete() {
UOW uow = null;
try {
uow = new UOW();
// Create a new object
PartAdditional object = (PartAdditional) uow.newPersistentInstance(PartAdditional.class);
object.setPart(PART);
// enter at least a blank string, since the field is mandatory
object.setField1(" ");
uow.add(object);
uow.commit();
// Now ensure that the record got created
uow = new UOW();
object = PartAdditional.findByPK(uow, PART);
assertNotNull("A PartAdditional object should have been created", object);
assertEquals(PART, object.getPart());
// Delete the bugger
uow.delete(object);
uow.commit();
// Now ensure that the record got deleted
uow = new UOW();
object = PartAdditional.findByPK(uow, PART);
assertNull("A PartAdditional object should have been deleted", object);
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
try {
if (uow != null)
uow.rollback();
} catch (Exception e) {
// do nothing
}
cleanupData(PART);
}
}
use of org.jaffa.persistence.domainobjects.PartAdditional in project jaffa-framework by jaffa-projects.
the class CharFieldTest method testUpdate.
/**
* Updates a record.
*/
public void testUpdate() {
UOW uow = null;
try {
uow = new UOW();
// Create a new object
PartAdditional object = (PartAdditional) uow.newPersistentInstance(PartAdditional.class);
object.setPart(PART);
// enter at least a blank string, since the field is mandatory
object.setField1(" ");
uow.add(object);
uow.commit();
// Now ensure that the record got created
uow = new UOW();
object = PartAdditional.findByPK(uow, PART);
assertNotNull("A PartAdditional object should have been created", object);
assertEquals(PART, object.getPart());
// Update the object
object.setField1("NEW VALUE");
object.setField2("");
object.setField3(" ");
uow.update(object);
uow.commit();
// Now ensure that the record got updated
uow = new UOW();
object = PartAdditional.findByPK(uow, PART);
assertNotNull("A PartAdditional object should have been updated", object);
assertEquals(PART, object.getPart());
assertEquals("NEW VALUE", object.getField1());
assertNull(object.getField2());
assertNull(object.getField3());
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
try {
if (uow != null)
uow.rollback();
} catch (Exception e) {
// do nothing
}
cleanupData(PART);
}
}
use of org.jaffa.persistence.domainobjects.PartAdditional in project jaffa-framework by jaffa-projects.
the class CharFieldTest method testJoinQueryBetweenCharAndVarchar.
/**
* Tests the sql:
* Select * from zz_jut_part_additional Where exists
* (select 1 from zz_jut_part Where zz_jut_part.part = trim(zz_jut_part_additional.part))
* This should return 1 record
*/
public void testJoinQueryBetweenCharAndVarchar() {
UOW uow = null;
try {
uow = new UOW();
// Create a new object
PartAdditional object = (PartAdditional) uow.newPersistentInstance(PartAdditional.class);
object.setPart(PART);
// enter at least a blank string, since the field is mandatory
object.setField1(" ");
uow.add(object);
uow.commit();
// Perform a join between PartAdditional and Part
uow = new UOW();
Criteria c1 = new Criteria();
c1.setTable(PartMeta.getName());
c1.addInnerCriteria(PartMeta.PART, PartAdditionalMeta.PART);
Criteria c2 = new Criteria();
c2.setTable(PartAdditionalMeta.getName());
c2.addAggregate(c1);
Collection col = uow.query(c2);
assertEquals("One record should have been retrieved", 1, col.size());
object = (PartAdditional) col.iterator().next();
assertEquals(PART, object.getPart());
assertNull(object.getField1());
assertNull(object.getField2());
assertNull(object.getField3());
// Now lets do a join between PartAdditional and Part, and a non-existent record
c1 = new Criteria();
c1.setTable(PartMeta.getName());
c1.addInnerCriteria(PartMeta.PART, PartAdditionalMeta.PART);
c2 = new Criteria();
c2.setTable(PartAdditionalMeta.getName());
c2.addAggregate(c1);
c2.addCriteria(PartAdditionalMeta.PART, "NON-EXISTENT-PART");
col = uow.query(c2);
assertEquals("No record should have been retrieved", 0, col.size());
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
try {
if (uow != null)
uow.rollback();
} catch (Exception e) {
// do nothing
}
cleanupData(PART);
}
}
use of org.jaffa.persistence.domainobjects.PartAdditional in project jaffa-framework by jaffa-projects.
the class CharFieldTest method testNotNullQuery.
/**
* Tests the sql:
* Select * from zz_jut_part_additional where field1 is not null and field1 != ' '
* This should return 1 record
*/
public void testNotNullQuery() {
UOW uow = null;
try {
uow = new UOW();
// Create a new object
PartAdditional object = (PartAdditional) uow.newPersistentInstance(PartAdditional.class);
object.setPart(PART);
// enter at least a blank string, since the field is mandatory
object.setField1(" ");
object.setField2("A VALUE");
uow.add(object);
uow.commit();
// Retrieve records where field2 is not null. Should get 1 record
uow = new UOW();
Criteria c = new Criteria();
c.setTable(PartAdditionalMeta.getName());
c.addCriteria(PartAdditionalMeta.FIELD2, Criteria.RELATIONAL_IS_NOT_NULL);
Collection col = uow.query(c);
assertEquals("One record should have been retrieved", 1, col.size());
object = (PartAdditional) col.iterator().next();
assertEquals(PART, object.getPart());
assertNull(object.getField1());
assertEquals("A VALUE", object.getField2());
assertNull(object.getField3());
// Retrieve records where field1 is not null. Nothing should be retrieved
uow = new UOW();
c = new Criteria();
c.setTable(PartAdditionalMeta.getName());
c.addCriteria(PartAdditionalMeta.FIELD1, Criteria.RELATIONAL_IS_NOT_NULL);
col = uow.query(c);
assertEquals("No record should have been retrieved", 0, col.size());
} catch (Exception e) {
e.printStackTrace();
fail();
} finally {
try {
if (uow != null)
uow.rollback();
} catch (Exception e) {
// do nothing
}
cleanupData(PART);
}
}
use of org.jaffa.persistence.domainobjects.PartAdditional in project jaffa-framework by jaffa-projects.
the class Part method newPartAdditionalObject.
/**
* Creates a new PartAdditional object and initializes the related fields.
* @throws ValidationException if an invalid value is passed.
* @throws FrameworkException Indicates some system error
* @return the related PartAdditional object with the initialized related fields.
*/
public PartAdditional newPartAdditionalObject() throws ValidationException, FrameworkException {
PartAdditional partAdditional = new PartAdditional();
partAdditional.setPart(getPart());
// .//GEN-BEGIN:partAdditionalObject_2_be
return partAdditional;
}
Aggregations