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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:37:46+00:00 2026-05-27T12:37:46+00:00

I have 2 classes which get saved in the google datastore. class product which

  • 0

I have 2 classes which get saved in the google datastore. class product which contains an arraylist of productdetails. now i have a hard time getting the arraylist returned back to me.
class product is detachable and when i try to acces the arraylist inside the object i get the error:

You have just attempted to access field "productDetailsArray" yet this field was not detached when you detached the object. Either dont access this field, or detach it when detaching the object.

Can anyone explain how I can also detach the arraylist from the google datastore?

the 2 classes im using are

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class Product implements Serializable{
   private static final long serialVersionUID = 1L;
   private static final Logger log = Logger.getLogger(Product.class.getName());
   @PrimaryKey
   @Persistent
   private String productNaam;
   @Persistent
   private String categorie;
   @Persistent
   private ArrayList<ProductDetails> productDetailsArray = new ArrayList<ProductDetails>();

   //getters and setter below.

   // I use this methode to fix a error resulting the arraylist from being org.datanucleus.sco.backed.ArrayList
   public void fix() {
     log.info("Fix()");
     ArrayList<ProductDetails> a = new ArrayList<ProductDetails>();
     Iterator<ProductDetails> itr = productDetailsArray.iterator();
     while (itr.hasNext()) {
        ProductDetails p = itr.next();
        log.info(p.getPlaats());
        a.add(p);
     }
   }
}

classe productdetails

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class ProductDetails implements Serializable{
    private static final long serialVersionUID = 1L;
    @PrimaryKey    
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    @Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
    private String encodedKey;  
    @Persistent
    private String winkel, plaats;
    @Persistent
    private double prijs;
    //getters and setters here.
}

the methode i’m using is in de DAO implementation to return the objects with there arraylist is.

public ArrayList<Product> productList() {
    PersistenceManager pm = PmfSingleton.get().getPersistenceManager();
    ArrayList<Product> products = new ArrayList<Product>();
    try {
        products.clear();
        pm.currentTransaction().begin();
        Extent<Product> ex = pm.getExtent(Product.class, true);
        Iterator<Product> itr = ex.iterator();
        while(itr.hasNext()) {
            Product tempProduct = itr.next();
            Product product = pm.detachCopy(tempProduct);
            //ArrayList<ProductDetails> pd = new ArrayList<ProductDetails>(product.getProductDetails());
            product.fix();
            products.add(product);
        }
        pm.currentTransaction().commit();
        ex.closeAll();
    } catch (Exception e) {
        pm.currentTransaction().rollback();
        throw new RuntimeException(e);
    } finally {
        pm.close();
    }
    return products;
}
  • 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-27T12:37:47+00:00Added an answer on May 27, 2026 at 12:37 pm

    Why not just follow the advice of that message ? Put the field in the fetch group if you want to detach it. Docs for DataNucleus tell clearly enough how to do that

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

Sidebar

Related Questions

I have classes which have automatic properties only like public customerName {get; set;}. They
I have a number of CSS attributes and Classes which get applied based on
Suppose we have 2 classes, Child, and the class from which it inherits, Parent.
I have a class which get all the bytes from a file, then it
I have two classes: public class Parent { public virtual long? ID { get;
I want to have an abstract class with 3 classes extending it which i
I have four classes which share some arrangement of four properties. I have currently
I have some classes which extends a superclass, and in the JSP I want
I have various classes which all contain address details, i.e. AddressLine1, AddressLine2, AddressLine3, Suburb,
I have two related classes which share a common interface and are both stored

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.