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

  • Home
  • SEARCH
  • 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 9296235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:47:21+00:00 2026-06-18T21:47:21+00:00

I’m using Java & GAE datastore to store, manage and retrieve some data for

  • 0

I’m using Java & GAE datastore to store, manage and retrieve some data for my application.

Basically I have two classes: Customer and Store. The idea is that one customer can have more than one store associated, and many customers can exist.

The structure of a customer is something like this:

<Customer>
   <id>id1</id>
       <Stores>
           <Store>
               <storeId>100</storeId>
               <city>Venice</city>
           </Store>
           <Store>
                <storeId>200</storeId>
                <city>Milan</city>
           </Store>
           <Store>
                <storeId>300</storeId>
                <city>Venice</city>
           </Store>
       </Stores>
 </Customer>

As I said before, there can be MANY customers:

<Customers>
    <Customer>
       ...
    </Customer>
    <Customer>
       ...
    </Customer>
</Customers>

I need to build a filter to get only a portion of these customers, passing to a query a “CITY” parameter:
For example, if I want to show Customers that has at least one Store located in Venice, I would do something like ( just to give you the idea)

GET Customer WHERE Customer.Store.City = 'Venice'

What I’d like to get is every Customer that has a Store located in a particular city.. but also, the Customer Object needs to have those stores! like this:

<Customer>
    <id>id1</id>
       <Stores>
           <Store>
               <storeId>100</storeId>
               <city>Venice</city>
           </Store>
           <Store>
               <storeId>300</storeId>
               <city>Venice</city>
           </Store>
        </Stores>
</Customer>
<Customer>
    <id>id2</id>
       <Stores>
           <Store>
               <storeId>700</storeId>
               <city>Venice</city>
           </Store>
        </Stores>
</Customer>

I can get those stores correctly, but I need to find a way to connect every store to his ancestor customer..

String city = 'something';
Query query = mgr.newQuery(Store.class, "city == '"+city+"' ");
List<Store> oggetti = (List<Store>) query.execute();

Any idea on how to do this?

I hope I was clear enough.. thanks in advance, best regards


Additional info:

class Customer:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Cacheable("false")
@FetchGroup(name="customerstores", members={@Persistent(name="storeList")})
public class Customer {

    @PrimaryKey
@Persistent
private String id= "";

    @Persistent
    @Unowned
private List<Store> storeList;

    //getters and setters here
    ....
}

Class Store:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Cacheable("false")
public class Store {

    @PrimaryKey
@Persistent
private String storeUniqueKey = "";

    @Persistent
    private String city = "";

    //getters and setters here
    ....
}
  • 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-06-18T21:47:22+00:00Added an answer on June 18, 2026 at 9:47 pm

    See if following code could fit your requirement.

    Query query = pm.newQuery(Customer.class);
    query.declareVariables("Customer store");
    query.setFilter(
        "this.stores.contains(store) && store.city == \"SomeCity\"");
    Collection result = (Collection)query.execute();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I'm using an ASP request returning a XML file containing some latin characters. By

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.