Package de.peacei.gae.foodsupplier.data.dao

Source Code of de.peacei.gae.foodsupplier.data.dao.CommentDAO

/**
*
*/
package de.peacei.gae.foodsupplier.data.dao;

import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;

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

import de.peacei.gae.foodsupplier.data.Comment;
import de.peacei.gae.foodsupplier.util.PMF;

/**
* @author peacei
*
*/
public class CommentDAO {
 
  @SuppressWarnings("unchecked")
  public List<Comment> getCommentsForMenu(Key menuKey) {
    List<Comment> comments = null;
   
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
     
      final Query query = pm.newQuery(Comment.class, "this.menuKey == m");
      query.declareParameters("com.google.appengine.api.datastore.Key m");
      comments = (List<Comment>) query.execute(menuKey);
     
    } catch(Exception e) {  }
   
    return comments;
  }
 
  public void saveComment(Comment comment) {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    try {
      pm.makePersistent(comment);
      pm.flush();
    } finally {
      pm.close();
    }
  }
}
TOP

Related Classes of de.peacei.gae.foodsupplier.data.dao.CommentDAO

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.