Java와 함께 Google AppEngine을 사용하고 있습니다.AppEngine 데이터 저장소 : "ID가 인 객체 ... 다른 객체 관리자가 관리합니다"
Object with id "[email protected]" is managed by a different Object Manager
나는 이것이 의미 또는 어디에서 어떻게이 오류에 대한 문서를 찾아 그것을 해결하는 방법 모르는 : 나는 몇 가지 데이터 저장소 기능을 사용하면 오류 메시지가 표시 얻고있다. 누구든지 나를 도울 수 있습니까? 내가 사용하는 코드는 다음과 같습니다
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class School {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private String shortname;
@Persistent
private String fullname;
@Persistent
@Order(extensions = @Extension(vendorName="datanucleus", key="list-ordering", value="code asc"))
private List<Teacher> Teachers;
...
public Teacher FindOrCreateTeacher(String code)
{
// Can we find the teacher without any database code?
Teacher newTeacher = FindTeacher(code);
if (newTeacher != null)
return newTeacher;
// Create the teacher:
PersistenceManager pm = PMF.get().getPersistenceManager();
Transaction tx = pm.currentTransaction();
try {
tx.begin();
for (Teacher teacher : Teachers) {
if (teacher.getCode() == code) {
tx.rollback();
return teacher;
}
}
newTeacher = new Teacher(code);
Teachers.add(newTeacher);
pm.makePersistent(newTeacher);
pm.makePersistent(Teachers);
tx.commit();
} finally {
tx.commit();
}
return newTeacher;
}
나는 "private List<Teacher> Teachers;
이"를 의미한다는 생각에 "소유 많은 한"관계.
재미있는 설명. +1 – VonC
PM 인스턴스에 적합한 수명이 더 무엇인지 나에게 설명 할 수 있습니까? 웹 앱을 작성한다고 가정 해 보겠습니다. 모든 페이지 요청시 열어야합니까? 또는 프로세스의 수명 동안 하나의 인스턴스를 열어 두어야합니까? (트랜잭션을 커밋하지만 PM을 닫지 않으면 메모리 누수가 발생하는 최악의 상황입니까? 내 데이터는 안전합니까?) –
프로세스는 얼마나 오래 걸립니까? 일반적인 웹 시스템은 요청 당 PM을 사용합니다. PM 작성은 비용이 많이 들지 않습니다 (PMF 작성은 * 비쌉니다). txns를 사용하는 경우 해당 PM과 비 트랜잭션 업데이트를 수행하지 않는 한 안전하게 PM을 열어 둘 수 있습니다. – DataNucleus