в моем профиле классе яотношение один к одному в JPA (AppEngine)
@OneToOne(cascade=CascadeType.PERSIST)
private ProfilePicture profilePic = null;
Мой метод в обновлении profilePic
public Profile updateUserProfilePic(Profile user) {
EntityManager em = EMF.get().createEntityManager();
em.getTransaction().begin();
Profile userx = em.find(Profile.class, user.getEmailAddress());
userx.setProfilePic(user.getProfilePic());
em.getTransaction().commit();
em.close();
return userx;
}
Когда updateUserProfilePic называется, просто добавить еще один profilePic в датасторе , он не заменяет существующий profilePic. Является ли моя реализация правильной? Я хочу обновить profilePic профиля.
и user.getProfilePic в каком состоянии? отстраненный? переходный? «Сообщает JDOHelper.getObjectState (obj)». И вы используете версию GAE JPA? – DataNucleus
JDOHelper.getObjectState (userx.getProfilePic()) возвращает переходный процесс, im используя JPA 1.0, GAE 1.6.4. Что означает переходный период? –