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>
템플릿의 vars에서 사례를보세요. "pessoa"는 "Pessoa"여야합니다. – GAEfan
코드의 오류 이외에도 엔티티를 작성하고 즉시 쿼리하면 오랫동안 표시되지 않을 수 있습니다. 최종 일관성에 대해 읽어보십시오. –