GWT >2.4 RequestFactory not saving child object changes

浪尽此生 提交于 2019-12-11 19:38:14

问题


I have a project that has been running on GWT 2.4 for some time (and 2.0 etc before that). When I switch it to GWT 2.5 or 2.6, child objects attached to my main Entity no longer save changes made to them. I don't change any code, but switching between 2.4 and 2.6, it breaks. I believe the changes don't get sent to the server. I'm watching the POST data, and it seems incomplete, missing the changes that I see being sent when on v2.4.

Are there changes to RequestFactory from 2.4-2.5 that would cause this? Something in the way I built it out that was not proper design? I appreciate any feedback!

Here's a sample retrieve/update pattern:

// 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) { }
});

Example Request interface:

@Service(value = MyEntityDao.class, locator = DaoLocator.class)
public interface MyEntityRequest extends RequestContext {
  Request<Void> save(MyEntityProxy entity);
}

Domain objects:

@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);
}

Server object:

@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;
}

Server persist:

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();
  } 
}

回答1:


It probably has something to do with https://code.google.com/p/google-web-toolkit/issues/detail?id=7827

TL;DR: yes, there were some changes in 2.5.



来源:https://stackoverflow.com/questions/24041553/gwt-2-4-requestfactory-not-saving-child-object-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!