Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6646769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:27:28+00:00 2026-05-26T00:27:28+00:00

I have the following code in which I query SimpleDb to get a list

  • 0

I have the following code in which I query SimpleDb to get a list of the items in my domain along with the “Favorited” attribute. Basically I am trying to update the users database to have the most recent amount of times each item has been “Favorited”.

itemNames[] works out perfectly. However, I am having trouble pulling out the attribute. I get to setting List Attributes which ends up being [{Name: Favorited, AlternateNameEncoding: null, Value: 5, AlternateValueEncoding: null, }]. From here though, I don’t know how to pull out the Value attribute.

End result I want favoritedValues[i] = 5

Also, it is possible that I am going about this the difficult way, is there an easier way to do it?

private void updateFavorites() {
    AmazonClientManager clientManager = new AmazonClientManager();

    AmazonSimpleDBClient aSDbClient = clientManager.sdb();

    String domainName = "domain";
    SelectRequest selectRequest2 = new SelectRequest( "select Favorited from `" + domainName + "`" ).withConsistentRead( true );

    List values = aSDbClient.select( selectRequest2 ).getItems();

    String[] itemNames = new String[ values.size() ];
    String[] favoritedValues = new String[ values.size()];


    for ( int i = 0; i < values.size(); i++ ) {
        itemNames[ i ] = ((Item)values.get( i )).getName();
        List attributes  = ((Item)values.get( i )).getAttributes();

        favoritedValues[i] = No idea what goes here
    }
}

The Dev guide wasn’t able to help me. Every time I searched for information via google I got information on ListViews which wasn’t what I was looking for.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:27:29+00:00Added an answer on May 26, 2026 at 12:27 am

    You can loop on the attributes and find their names and values.

    List<Item> values;
    Item currentItem = buffer.get(i);
    itemNames[i] = currentItem.getName();
    List<Attribute> currentAttributes = currentItem.getAttributes();
    String favorited = "";
    for (Attribute anAttribute : currentAttributes) {
        if (anAttribute.getName().equals("Favorited")) {
            favorited = anAttribute.getValue();
        }
    }
    

    Incidentally I find this syntax rather awkward. To get an attribute with a certain name you’ve to loop until you find it. By the way you can as well find it multiple times, because attributes can have multiple values. You can also find some other attributes in the middle, since attributes are not sorted.

    To facilitate the process I wrote a small library AmazonSdbHelper, that allows a syntax like the following.

    PersistenceInterface store = new AmazonSdbHelper();
    store.setDomain("domain");
    store.query("SELECT * FROM domain");
    while (store.hasNext()) {
        String key = store.next();
        String address = store.getAttributeAsString("address");
        Collection<String> phones = store.getAttributeAsCollection("phones");
        int visits = store.getAttributeAsInt("visits");
    }
    

    Even better there is a project called SimpleJpa, that implements JPA for Amazon. I would like to try it, anyone has experience with it?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have somebody elses code (C# ASP.Net) which contains the following query: string query
I'm trying to use opengl in C#. I have following code which fails with
I have the following code which works FANTASTIC. Except - It is a sub-query
I have the following code which builds a Generic List of Abc from a
I have the following query in ASP.NET/C# code which is failing to return any
I am trying to write code for registration form which have the following fields.
I have following Code Block Which I tried to optimize in the Optimized section
I have the following code which works just fine when the method is POST,
I have the following code which works fine. However, I only want to return
I have the following code which should put programs startable in Bash. if [

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.