Created
March 8, 2012 07:37
-
-
Save enesakar/1999425 to your computer and use it in GitHub Desktop.
hazelcast simpledb load implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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