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 6653919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:19:42+00:00 2026-05-26T01:19:42+00:00

Hi I’m trying to retrieve a linkedhashset from the Google datastore but nothing seems

  • 0

Hi I’m trying to retrieve a linkedhashset from the Google datastore but nothing seems to happen. I want to display the results in a Grid using GWT on a page. I have put system.out.println() in all the classes to see where I go wrong but it only shows one and I don’t recieve any errors. I use 6 classes 2 in the server package(ContactDAOJdo/ContactServiceImpl) and 4 in the client package(ContactService/ContactServiceAsync/ContactListDelegate/ContactListGui). I hope someone can explain why this isn’t worken and point me in the right direction.

public class ContactDAOJdo implements ContactDAO {
  @SuppressWarnings("unchecked")
  @Override
  public LinkedHashSet<Contact> listContacts() {
    PersistenceManager pm = PmfSingleton.get().getPersistenceManager(); 
    String query = "select from " + Contact.class.getName();
    System.out.print("ContactDAOJdo: ");
    return (LinkedHashSet<Contact>) pm.newQuery(query).execute();
  }
}

public class ContactServiceImpl extends RemoteServiceServlet implements ContactService{
  private static final long serialVersionUID = 1L;
  private ContactDAO contactDAO = new ContactDAOJdo() {
  @Override
  public LinkedHashSet<Contact> listContacts() {
    LinkedHashSet<Contact> contacts = contactDAO.listContacts();
    System.out.println("service imp "+contacts);
    return contacts;
  }
}

@RemoteServiceRelativePath("contact")
public interface ContactService extends RemoteService {
  LinkedHashSet<Contact> listContacts();
}

public interface ContactServiceAsync {
  void listContacts(AsyncCallback<LinkedHashSet <Contact>> callback);
}

public class ListContactDelegate {
private ContactServiceAsync contactService = GWT.create(ContactService.class);
ListContactGUI gui;
void listContacts(){
    contactService.listContacts(new AsyncCallback<LinkedHashSet<Contact>> () {
        public void onFailure(Throwable caught) {
            gui.service_eventListContactenFailed(caught);
            System.out.println("delegate "+caught);
        }
        public void onSuccess(LinkedHashSet<Contact> result) {
            gui.service_eventListRetrievedFromService(result);
            System.out.println("delegate "+result);
        }
    });
 }
}

public class ListContactGUI {
protected Grid contactlijst;
protected ListContactDelegate listContactService;
private Label status;

public void init() {
    status = new Label();
    contactlijst = new Grid();
    contactlijst.setVisible(false);
    status.setText("Contact list is being retrieved"); 
    placeWidgets();

}

public void service_eventListRetrievedFromService(LinkedHashSet<Contact> result){
    System.out.println("1 service eventListRetreivedFromService "+result);
    status.setText("Retrieved contactlist list");
    contactlijst.setVisible(true);
    this.contactlijst.clear();
    this.contactlijst.resizeRows(1 + result.size());
    int row = 1;
    this.contactlijst.setWidget(0, 0, new Label ("Voornaam"));
    this.contactlijst.setWidget(0, 1, new Label ("Achternaam"));
    for(Contact contact: result) {
        this.contactlijst.setWidget(row, 0, new Label (contact.getVoornaam()));
        this.contactlijst.setWidget(row, 1, new Label (contact.getVoornaam()));
        row++;
        System.out.println("voornaam: "+contact.getVoornaam());
    }
    System.out.println("2 service eventListRetreivedFromService "+result);
}

public void placeWidgets() {
    System.out.println("placewidget inside listcontactgui" + contactlijst);
    RootPanel.get("status").add(status);
    RootPanel.get("contactlijst").add(contactlijst);
}

public void service_eventListContactenFailed(Throwable caught) {
    status.setText("Unable to retrieve contact list from database.");
}
}
  • 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-26T01:19:42+00:00Added an answer on May 26, 2026 at 1:19 am

    It could be the query returns a lazy list. Which means not all values are in the list at the moment the list is send to the client. I used a trick to just call size() on the list (not sure how I got to that solution, but seems to work):

    public LinkedHashSet<Contact> listContacts() {
      final PersistenceManager pm = PmfSingleton.get().getPersistenceManager(); 
      try {        
        final LinkedHashSet<Contact> contacts =
            (LinkedHashSet<Contact>) pm.newQuery(Contact.class).execute();
        contacts.size(); // this triggers to get all values.
        return contacts;
      } finally {
        pm.close();
      }
    

    }

    But I’m not sure if this is the best practice…

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want to count how many characters a certain string has in PHP, but
I have a French site that I want to parse, but am running into
i want to parse a xhtml file and display in UITableView. what is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to construct a data frame in an Rcpp function, but when I
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.