2014-06-16 16 views
0

저는 GAE의 초보자이며 응용 프로그램에서 삽입 작업을 수행하고 있지만 데이터베이스에서 데이터를 반환하지는 않습니다. 로그에 오류가 표시되지 않습니다. 무엇이 잘못 되었나요?App Engine에서 데이터 가져 오기

public List<Pessoa> listPessoas() 
{ 
    EntityManager em = EMFService.get().createEntityManager(); 
    List<Pessoa> lista; 

    try 
    { 
     Query q = em.createQuery("select p from Pessoa p"); 
     lista = (List<Pessoa>) q.getResultList(); 

    } 
    finally 
    { 
     em.close(); 
    } 


    return lista; 

} 

내 JSP 페이지 따릅니다 :

import javax.persistence.EntityManagerFactory; 

import javax.persistence.Persistence; 

public class EMFService { 

    public static final EntityManagerFactory emfInstance = 
      Persistence.createEntityManagerFactory("transactions-optional"); 

    private EMFService(){} 

    public static EntityManagerFactory get() 
    { 
     return emfInstance; 
    } 
} 

내 선택 클래스 따릅니다 :

내 공장 클래스 따릅니다

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<title>Pessoas</title> 
</head> 
<body> 

<table border=1> 
     <thead> 
      <tr> 
       <th>Nome</th> 
       <th>Idade</th> 
      </tr> 
     </thead> 
     <tbody> 
      <c:forEach items="${pessoas}" var="pessoa"> 
       <tr> 
        <td><c:out value="${pessoa.nome}" /></td> 
        <td><c:out value="${pessoa.idade}" /></td> 
       </tr> 
      </c:forEach> 
     </tbody> 
    </table> 

</body> 
</html> 
+0

템플릿의 vars에서 사례를보세요. "pessoa"는 "Pessoa"여야합니다. – GAEfan

+0

코드의 오류 이외에도 엔티티를 작성하고 즉시 쿼리하면 오랫동안 표시되지 않을 수 있습니다. 최종 일관성에 대해 읽어보십시오. –

답변

0

확인하는 데이터 저장소에있는 변수의 경우 JSP 페이지의 경우와 일치합니다. 즉, 데이터에 "Pessoa"이 있으므로 tore도 JSP 페이지에서 "Pessoa"이어야합니다. 또한, Firebug를 사용하여 응용 프로그램을 디버깅해야합니다. console.log()을 사용하여 데이터 저장소에서 반환되는 내용을 확인하십시오.

관련 문제