Hi all,

Need a little help in using the persistence of appengine. First of all
the code:


Feed.java
=========================
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Feed {

        @Persistent
        final String title;
        @Persistent
        final String link;
        @Persistent
        final String description;
        @Persistent
        final Date pubDate;
//    @PrimaryKey
//    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
//    private Key key;

    @Persistent (valueStrategy = IdGeneratorStrategy.IDENTITY)
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    @PrimaryKey
    private Long id;

        public Feed(String title, String link, String description,Date
pubDate) {
                                this.title = title;
                                this.link = link;
                                this.description = description;
                                this.pubDate = pubDate;
        }

        public String getTitle() {
                return title;
        }

        public String getLink() {
                return link;
        }

        public String getDescription() {
                int junkIndex = description.indexOf("More horoscopes");
                return description.substring(0, junkIndex-1);
        }

        public Date getPubDate() {
                return pubDate;
        }

}

=======================================
Code for saving the data:-
=======================================
private static List<Feed> feeds;

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

try {
        pm.makePersistentAll(feeds);
    } finally {
        pm.close();
    }

=========================================
Code for retrieving data:-
========================================

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


                 String query = "select from " + Feed.class.getName() ;
                 List<Feed> feeds = (List<Feed>) pm.newQuery(query).execute();
                 for(int i=0;i<feeds.size();i++) {
                         Feed feed = feeds.get(i);
                         if (feed.getTitle().contains("test")) return feed;
                 }
                return  null;
===================================
The problem:-
===================================
While saving I can see that proper title,description etc are getting
stored in the Feed class. But while retreiving, the values are coming
as NULL.

So I am getting null pointer at

if (feed.getTitle().contains("test"))


Could anybody please help me with this?

-- 
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 google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to