我有一些这样的代码:
PersistenceManager pm=PMF.get().getPersistenceManager();
String query="select from "+PayPal_Message.class.getName()+" where processed == false order by time desc";
List<PayPal_Message> messages=(List<PayPal_Message>)pm.newQuery(query).execute();
if (messages.isEmpty())
{
}
else
{
for (PayPal_Message g : messages)
{
Contact_Info_Entry A_Contact_Entry=Process_PayPal_Message_To_Get_A_License(g.getContent().getValue());
pm=PMF.get().getPersistenceManager();
try
{
pm.makePersistent(A_Contact_Entry);
g.setProcessed(true);
pm.makePersistent(g);
}
catch (Exception e)
{
Send_Email(Email_From,"nm67@yahoo.com","Servlet Error Message [ "+time+" ]",new Text(e.toString()));
}
// finally { pm.close(); }
}
}
pm.close();
我想知道在关闭它之前使用上面的pm处理多个对象是否可以。还是我必须获取并关闭 pm 才能处理每个对象?