Class keyCls = priKey.getClass();
DatabaseEntry keyEntry2 = new DatabaseEntry();
DatabaseEntry dataEntry2 = new DatabaseEntry();
/* Write object, read it back and validate (compare) it. */
PersistEntityBinding entityBinding =
new PersistEntityBinding(catalog, entityCls.getName(), false);
entityBinding.objectToData(entity, dataEntry);
entityBinding.objectToKey(entity, keyEntry);
Object entity2 = entityBinding.entryToObject(keyEntry, dataEntry);
entity.validate(entity2);
/* Read back the primary key and validate it. */
PersistKeyBinding keyBinding =
new PersistKeyBinding(catalog, keyCls.getName(), false);
Object priKey2 = keyBinding.entryToObject(keyEntry);
assertEquals(priKey, priKey2);
keyBinding.objectToEntry(priKey2, keyEntry2);
assertEquals(keyEntry, keyEntry2);
/* Check raw entity binding. */
PersistEntityBinding rawEntityBinding =
new PersistEntityBinding(catalog, entityCls.getName(), true);
RawObject rawEntity =
(RawObject) rawEntityBinding.entryToObject(keyEntry, dataEntry);
rawEntityBinding.objectToKey(rawEntity, keyEntry2);
rawEntityBinding.objectToData(rawEntity, dataEntry2);
entity2 = entityBinding.entryToObject(keyEntry2, dataEntry2);
entity.validate(entity2);
RawObject rawEntity2 =
(RawObject) rawEntityBinding.entryToObject(keyEntry2, dataEntry2);
assertEquals(rawEntity, rawEntity2);
assertEquals(dataEntry, dataEntry2);
assertEquals(keyEntry, keyEntry2);
/* Check that raw entity can be converted to a regular entity. */