ARTICLE AD BOX
I’m testing GridDB with a simple Java setup and ran into something confusing while trying to fetch a row by its key.
I insert a row into a collection container, and the insert seems to work fine (no errors). But when I try to retrieve the same row using the key, I sometimes get null.
Here’s a simplified version of what I’m doing:
Properties props = new Properties(); props.setProperty("notificationAddress", "239.0.0.1"); props.setProperty("notificationPort", "31999"); props.setProperty("clusterName", "myCluster"); props.setProperty("user", "admin"); props.setProperty("password", "admin"); GridStore store = GridStoreFactory.getInstance().getGridStore(props); // Assume container already created Container<Integer, Row> container = store.getContainer("Users"); // Insert row Row row = container.createRow(); row.setInteger(0, 1); row.setString(1, "John"); container.put(row); // Try to fetch Row fetched = container.get(1); if (fetched == null) { System.out.println("Row not found"); } else { System.out.println(fetched.getString(1)); }Sometimes this prints "Row not found" even though I just inserted it.
I’m not sure if I’m missing something related to:
transaction handling
auto-commit behavior
or container configuration
Any suggestions would help, I feel like I’m missing something basic here.
