@Test
public void testRawStuff() {
setupModel();
NoSqlTypedSession s = mgr.getTypedSession();
TypedRow row2 = s.createTypedRow("Owner");
row2.setRowKey("myoneid");
row2.addColumn("name", "dean");
s.put("Owner", row2);
TypedRow row = s.createTypedRow("MyRaceCar");
row.setRowKey("myoneid");
row.addColumn("carOwner", row2.getRowKey());
s.put("MyRaceCar", row);
s.flush();
NoSqlEntityManager mgr2 = factory.createEntityManager();
NoSqlTypedSession s2 = mgr2.getTypedSession();
s2.remove("Owner", row2);
s2.flush();
TypedRow result = s2.find("MyRaceCar", row.getRowKey());
Assert.assertNotNull(result);
TypedRow result2 = s2.find("Owner", row2.getRowKey());
Assert.assertNull(result2);
/* if (result.getColumn("carOwner") != null) {
Object fk = result.getColumn("carOwner").getValue();
Object rowId = row2.getRowKey();
//Assert.assertEquals(rowId, fk);
}
else {*/
// it is saved as a composite column now so no need to test as above, test as composite
Object rowId = row2.getRowKey();
for(TypedColumn c : result.getColumnsAsColl()) {
DboColumnMeta colMeta = c.getColumnMeta();
if(colMeta != null) {
String fullName = c.getName();
String fkcomposite = fullName.substring(fullName.indexOf(".")+1);
Assert.assertEquals(rowId.toString(), fkcomposite);
}
}
//}
QueryResult qResult = s2.createQueryCursor("select * from MyRaceCar", 50);
Cursor<KeyValue<TypedRow>> primView = qResult.getPrimaryViewCursor();
Assert.assertTrue(primView.next());
KeyValue<TypedRow> current = primView.getCurrent();
TypedRow resultRow = current.getValue();
Assert.assertEquals(row.getRowKey(), resultRow.getRowKey());
Cursor<List<TypedRow>> cursor = qResult.getAllViewsCursor();
Assert.assertTrue(cursor.next());
List<TypedRow> theRow = cursor.getCurrent();
Assert.assertEquals(1, theRow.size());
TypedRow myRow = theRow.get(0);
Assert.assertEquals(row.getRowKey(), myRow.getRowKey());
QueryResult rResult = s2.createQueryCursor("select * from Owner", 50);
Assert.assertFalse(rResult.getCursor().next());
}