GWT> 2.4 RequestFactory不保存子对象更改 [英] GWT >2.4 RequestFactory not saving child object changes
问题描述
我有一段时间以来一直在GWT 2.4上运行的项目(以及之前的2.0版本)。当我将它切换到GWT 2.5或2.6时,附加到我的主实体的子对象不再保存对它们所做的更改。我不更改任何代码,但在2.4和2.6之间切换,它会中断。我相信这些更改不会发送到服务器。我正在看POST数据,看起来不完整,错过了我在v2.4上发送的更改。
是否有从2.4-2.5更改RequestFactory会导致此问题?我建立它的方式是不合适的设计?
以下是一个取回/更新模式示例:
//从服务器获取对象
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;
}
});
//编辑客户端..
//保存更新的对象
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>保存(MyEntityProxy实体);
}
域对象:
@ProxyFor(MyEntity.class,locator = DomainObjectLocator.class)
public interface MyEntityProxy extends EntityProxy {
Integer getId();
设置< ChildProxy>的getChildren();
void setChildren(Set< ChildProxy> children);
$ b @ProxyFor(Child.class,locator = DomainObjectLocator.class)
public interface ChildProxy extends EntityProxy {
Integer getId();
String getName();
void setName(String name);
$ / code>
服务器对象:
@Entity
@Table(name =MyEntity)
@BatchSize(size = 25)
public class MyEntity extends DomainObject {
@OneToMany(mappedBy =myEntity)
@BatchSize(size = 25)
@Cascade(CascadeType.ALL)
private Set< Child>儿童;
服务器持续存在:
public static void save(MyEntity myEntity){
Session session = HibernateUtil.getSessionFactory()。getCurrentSession();
session.beginTransaction();
尝试{
myEntity =(MyEntity)session.merge(myEntity);
} catch(Exception e){
e.printStackTrace();
session.getTransaction()。rollback();
} finally {
session.getTransaction()。commit();
}
}
它可能与 https://code.google.com有关.com / p / google-web-toolkit / issues / detail?id = 7827
TL;是的,2.5有一些变化。
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();
}
}
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.
这篇关于GWT> 2.4 RequestFactory不保存子对象更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!