expected.add(new ORecordId("#77:21"));
expected.add(new ORecordId("#77:22"));
ODocument doc = new ODocument();
final ORidBag bag = new ORidBag();
bag.addAll(expected);
doc.field("ridbag", bag);
assertEmbedded(bag.isEmbedded());
doc.save();
final ORID id = doc.getIdentity();
OStorage storage = database.getStorage();
database.close();
storage.close(true, false);
database.open("admin", "admin");
doc = database.load(id);
doc.setLazyLoad(false);
final ORidBag loaded = doc.field("ridbag");
assertEmbedded(loaded.isEmbedded());
Assert.assertEquals(loaded.size(), expected.size());
for (OIdentifiable identifiable : loaded)
Assert.assertTrue(expected.remove(identifiable));
Assert.assertTrue(expected.isEmpty());
}