Skip to content

Instantly share code, notes, and snippets.

@enesakar
Created March 8, 2012 07:37
Show Gist options
  • Select an option

  • Save enesakar/1999425 to your computer and use it in GitHub Desktop.

Select an option

Save enesakar/1999425 to your computer and use it in GitHub Desktop.
hazelcast simpledb load implementation
public Contact load(String key) {
SelectRequest req = new SelectRequest("select * from Contact where itemName() = '" + key + "'");
SelectResult result = sdb.select(req);
if (!result.getItems().isEmpty()) {
Item item = result.getItems().get(0);
return formContact(item.getAttributes());
} else {
return null;
}
}
private Contact formContact(List<Attribute> attributes) {
Contact contact = new Contact();
for (Attribute attr : attributes) {
if (attr.getName().equals("Name"))
contact.setName(attr.getValue());
else if (attr.getName().equals("Phone"))
contact.setPhone(attr.getValue());
}
return contact;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment