我有一個應用程序在Google App Engine中工作正常。我意識到,我忘了實現equals和hashCode(我需要使用集合中的對象)的JDO增強對象。所以我做了。我在這些實現中並沒有做任何特別的事情,實際上我只是使用Eclipse來生成它們。像這樣:Google App Engine,JDO和equals/hashCode
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String appleId;
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((appleId == null) ? 0 : appleId.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
User other = (User) obj;
if (appleId == null) {
if (other.appleId != null)
return false;
} else if (!appleId.equals(other.appleId))
return false;
return true;
}
所以現在,當我嘗試打在應用程序中的任何URL,此異常得到投擲:
/ADDUSER javax.jdo.JDOUserException:持久化類「類融爲一體。 bpapa.myapp.domain.User似乎沒有得到增強,您可能需要重新運行增強器並檢查輸出中的錯誤。「在數據庫中沒有表格,但操作需要它。請檢查這個類的元數據的規範。 在org.datanucleus.jdo.NucleusJDOHelper.getJDOExceptionForNucleusException(NucleusJDOHelper.java:427) 在org.datanucleus.jdo.JDOQuery.execute(JDOQuery.java:249) 在com.bpapa.myapp.servlet.AddUserServlet.doPost( AddUserServlet.java:34)
任何想法,我做錯了什麼?
做乾淨的固定的東西。 – bpapa 2009-11-01 04:06:01