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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T10:41:20+00:00 2026-06-03T10:41:20+00:00

I am using the local-development version of App Engine’s JDO implementation. When I query

  • 0

I am using the local-development version of App Engine’s JDO implementation. When I query an object that has contains other objects as embedded fields, the embedded fields are returned as null.

For example, lets say this is the main object that I am persisting:

@PersistenceCapable
public class Branch {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private String name;

    @Persistent
    private Address address;

            ...
}

and this my embedded object:

@PersistenceCapable(embeddedOnly="true")
public class Address {

    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private String street;

    @Persistent
    private String city;

            ...
}

the following code does not retrieve the embedded object:

    PersistenceManager pm = MyPersistenceManagerFactory.get().getPersistenceManager();

    Branch branch = null;
    try {
        branch = pm.getObjectById(Branch.class, branchId);
    }
    catch (JDOObjectNotFoundException onfe) {
        // not found
    }
    catch (Exception e) {
        // failed
    }
    finally {
        pm.close();
    }

Does anyone have a solution for this? How can I retrieve the Branch object along with its embedded Address field?

  • 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-03T10:41:22+00:00Added an answer on June 3, 2026 at 10:41 am

    I had a similar problem and found that embedded fields are not included in the default fetch group. To have the required field loaded you will either have to call the getter for it before closing the persistence manager or set the fetch group to load all fields.

    This means the following…

    branch = pm.getObjectById(Branch.class, branchId);
    pm.close();
    branch.getAddress();  // this is null
    
    branch = pm.getObjectById(Branch.class, branchId);
    branch.getAddress();  // this is not null
    pm.close();
    branch.getAddress();  // neither is this
    

    So, you would need to change your code as follows:

    Branch branch = null;
    try {
        branch = pm.getObjectById(Branch.class, branchId);
        branch.getAddress();
    }
    catch (JDOObjectNotFoundException onfe) {
        // not found
    }
    catch (Exception e) {
        // failed
    }
    finally {
        pm.close();
    }
    

    Alternatively, you can set your fetch group to include all fields as follows…

    pm.getFetchPlan().setGroup(FetchGroup.ALL);
    branch = pm.getObjectById(Branch.class, branchId);
    pm.close();
    branch.getAddress();  // this is not null
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using PHP version 5.3.2 on both my local development server and remote web
I'm using a local machine for development that needs to allow Admin Party (everyone
I'm trying to setup NServiceBus in Azure. During local development I am using the
I recently moved my whole local web development area over to using MacPorts stuff,
I am building an internet site, using my local machine as the development box
Using local variables seems advisable in a partial that could be used application-wide to
I have a JEE5 application that exposes services using (local) session beans. When an
I have a local development webserver set up using Win7 and IIS7. I often
I am running the development version of Django and it appears that the filebrowser
I'm testing a Google App Engine application where I've started using task queues to

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.