List typesDefined = types.define(types2define);
// Create an empty data graph and add a root object, an instance of customerType
//
DataGraph dataGraph = SDOUtil.createDataGraph();
Type customerTypeDefined = (Type) typesDefined.get(1);
DataObject customer1 = dataGraph.createRootObject(customerTypeDefined);
customer1.setInt("custNum", 1);
customer1.set("firstName", "John");
customer1.set("lastName", "Adams");
DataObject address = customer1.createDataObject("address");
address.set("addrSt", "577 Airport Blvd");
SDOUtil.registerDataGraphTypes(dataGraph, typesDefined);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
SDOUtil.saveDataGraph(dataGraph, baos, null);
//SDOUtil.saveDataGraph(dataGraph, System.out, null);
byte[] serialized = baos.toByteArray();
ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
DataGraph loadedDataGraph = SDOUtil.loadDataGraph(bais, null, SDOUtil.createTypeHelper());
DataObject loadedRootObject = loadedDataGraph.getRootObject();
assertNotSame(loadedRootObject.getType(), customer1.getType());
// EqualityHelper requires same Type
assertEquals(loadedRootObject.getInt("custNum"), customer1.getInt("custNum"));
assertEquals(loadedRootObject.get("firstName"), customer1.get("firstName"));