I have a persistent object, Category (code below)  (it has no links to
other persistent objects) it was working fine and has just stopped
saving all of a sudden.

Basically i have a hardcoded list that i want to commit to the
database on the first time which is what this code does.

There haven't been any changes to the object and the code to make it
persistent. i have deleted the databases and indexes. I have stepped
through the code and all lines execute

I am trying to get ideas on what to try, Really need to get it working
as i have just finished my app and was just about to release.


The mnethd for saving is:-
-------------------------------------------------------------------------------------------------------------------------------
public void createCategories() {
                PersistenceManager pm;
                pm=PMF.get().getPersistenceManager();
                int ctrTop=0;
                for (String[] catTop: Category.itunesCategoriesTexts) {
                        int ctr = 0;
                        Category parent = null;
                        for (String cats: catTop) {
                                Category c = new Category();
                                c.setText(cats);
                                c.setTextClean(Category.cleanCatName(cats));
                                if (ctr>0) {
                                        c.setParent(parent.getId());
                                } else {
                                        parent=c;
                                }
                                pm.makePersistent(c);
                                ctr++;
                        }
                        ctrTop++;
                }

                pm.close();
        }
-------------------------------------------------------------------------------------------------------------------------------


The code for the Category persistent object is here:
-------------------------------------------------------------------------------------------------------------------------------
package net.robmunro.mypod.web.db;

import java.util.ArrayList;
import java.util.List;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Category {
        // the first entry is the parent category
        public static final String[][] itunesCategoriesTexts= {
                {"Arts","Design","Fashion & 
Beauty","Food","Literature","Performing
Arts","Visual Arts"},
                {"Business","Business News","Careers","Investing","Management &
Marketing","Shopping"},
                {"Comedy"},
                {"Education","Education Technology","Higher
Education","K-12","Language Courses","Training"},
                {"Games & Hobbies","Automotive","Aviation","Hobbies","Other
Games","Video Games"},
                {"Government & Organizations","Local","National","Non-
Profit","Regional"},
                {"Health","Alternative Health","Fitness & Nutrition","Self-
Help","Sexuality"},
                {"Kids & Family"},
                {"Music"},
                {"News & Politics"},
                {"Religion &
Spirituality","Buddhism","Christianity","Hinduism","Islam","Judaism","Other","Spirituality"},
                {"Science & Medicine","Medicine","Natural Sciences","Social
Sciences"},
                {"Society & Culture","History","Personal
Journals","Philosophy","Places & Travel"},
                {"Sports & Recreation","Amateur","College & High
School","Outdoor","Professional"},
                {"Technology","Gadgets","Tech News","Podcasting","Software 
How-To"},
                {"TV & Film"},
                {"Uncategorised"}
        };
        public static String cleanCatName(String categoryName) {
                categoryName=categoryName.toLowerCase();
                if (categoryName.indexOf("&")>-1) {
                        categoryName=categoryName.replace("&", "&");
                }
                if (categoryName.indexOf("amp;")>-1) {
                        categoryName=categoryName.replace("amp;", "&");
                }
                if (categoryName.indexOf("&amp")>-1) {
                        categoryName=categoryName.replace("&amp", "&");
                }
                categoryName=categoryName.replaceAll("&", "and");
                categoryName=categoryName.replaceAll(" ", "");
                return categoryName;
        }




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

        @Persistent
        private String text;

        @Persistent
        private String textClean;

        @Persistent
        private Key parent;

        List<Category> children=new ArrayList<Category>();

        public Key getId() {
                return id;
        }

        public void setId(Key id) {
                this.id = id;
        }

        public String getText() {
                return text;
        }

        public void setText(String text) {
                this.text = text;
        }

        public Key getParent() {
                return parent;
        }

        public void setParent(Key parent) {
                this.parent = parent;
        }

        public String getTextClean() {
                return textClean;
        }

        public void setTextClean(String textClean) {
                this.textClean = textClean;
        }

        public List<Category> getChildren() {
                return children;
        }

        public void setChildren(List<Category> children) {
                this.children = children;
        }
}
-------------------------------------------------------------------------------------------------------------------------------

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to