Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion to many list is empty on second retrieval
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Matthew  
View profile  
 More options Nov 6 2012, 12:52 am
From: Matthew <mkrueger....@gmail.com>
Date: Mon, 5 Nov 2012 21:52:30 -0800 (PST)
Local: Tues, Nov 6 2012 12:52 am
Subject: to many list is empty on second retrieval

Hi - I'm having an issue getting to-many lists to populate correctly.  I'm
guessing I'm just misunderstanding something so I appreciate any help I can
get.

I have an entity named "Product" that has a list of Images (1 product has
many images).  The relationship seems to be setup properly.

After I create a new Product entity, insert, then add all the Images to the
list of Images on the Product entity everything seems fine.  The first time
I query for the newly created Product, the call to getImages returns a list
with the expected number of images in it.

However, the next time I try to query for the Product the call to getImages
on the resulting Product entity returns an empty list (all other properties
on the Product entity that aren't lists are populated correctly).  If I
perform a query to get the list of images separately for images by product
id, the expected images are returned...it just seems like the link between
Product -> Images has been broken somehow.

I've read there is some caching that greenDao does, but I'm not sure it
applies in this case - or if it does, how can I make it populate the to
many lists when I query for a Product?

I'm not sure if it matters, but to query for the Product I have to use a
"StringCondition" because to get the right list of products I need to join
to another table.  Here is the query to get the list of Products back just
in case you're curious (CAT_PROD is the join table linking Product and
Category together, which is necessary to get the list of Products in a
specific Category):

List<Product> prod = productDao.queryBuilder().where(

  new StringCondition("PRODUCT_ID IN (SELECT CAT_PROD.P_ID from CAT_PROD
WHERE CAT_PROD.C_ID = " + catId + " AND CAT_PROD.P_ID = " +
item.getItemId() + ")")).list();

Like I said before, the first time this query runs after inserting the
product, product.getImages() returns the expected list of images.
 Subsequent runs of the query result in empty lists when you call
product.getImages().

Thanks in advance for any help, I'm really stuck.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.