我有一个项目已经在GWT 2.4上运行了一段时间(之前是2.0等)。当我将其切换到GWT 2.5或2.6时,附加到我的主实体的子对象不再保存对它们所做的更改。我没有更改任何代码,但在2.4和2.6之间切换,它会中断。我相信这些更改不会发送到服务器。我正在观看POST数据,看起来不完整,缺少我在v2.4上发送的更改。
是否会对2.4-2.5中的RequestFactory进行更改?我构建它的方式是不是正确的设计?我感谢任何反馈!
这是一个示例检索/更新模式:
// Retrieve object from server
MyEntityRequest request = App.getRequestFactory().myEntityRequest();
MyEntityProxy myEntity;
request.get(id).with("child").fire(new Receiver<MyEntityProxy>() {
@Override
public void onSuccess(MyEntityProxy response) {
request = App.getRequestFactory().myEntityRequest();
myEntity = response;
}
});
// Edits made client side..
// Save updated object
myEntity = request.edit(myEntity);
myEntity.childEntity.setName("new value");
request.save(myEntity).fire(new Receiver<MyEntityProxy>() {
@Override
public void onSuccess(Void) { }
});
示例请求界面:
@Service(value = MyEntityDao.class, locator = DaoLocator.class)
public interface MyEntityRequest extends RequestContext {
Request<Void> save(MyEntityProxy entity);
}
域对象:
@ProxyFor(MyEntity.class, locator=DomainObjectLocator.class)
public interface MyEntityProxy extends EntityProxy {
Integer getId();
Set<ChildProxy> getChildren();
void setChildren(Set<ChildProxy> children);
}
@ProxyFor(Child.class, locator=DomainObjectLocator.class)
public interface ChildProxy extends EntityProxy {
Integer getId();
String getName();
void setName(String name);
}
服务器对象:
@Entity
@Table (name="MyEntity")
@BatchSize(size=25)
public class MyEntity extends DomainObject {
@OneToMany (mappedBy = "myEntity")
@BatchSize(size=25)
@Cascade(CascadeType.ALL)
private Set<Child> children;
}
服务器持续存在:
public static Void save(MyEntity myEntity) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
try {
myEntity = (MyEntity) session.merge(myEntity);
} catch (Exception e) {
e.printStackTrace();
session.getTransaction().rollback();
} finally {
session.getTransaction().commit();
}
}
答案 0 :(得分:1)
这可能与https://code.google.com/p/google-web-toolkit/issues/detail?id=7827
有关TL; DR:是的,2.5中有一些变化。