Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/28.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有集合子集合的GWT RequestFactory_Gwt_Requestfactory_Open Session In View - Fatal编程技术网

具有集合子集合的GWT RequestFactory

具有集合子集合的GWT RequestFactory,gwt,requestfactory,open-session-in-view,Gwt,Requestfactory,Open Session In View,我对RequestFactory有一个小问题,关于以集合的形式持久化子集合。我使用的是2.5,后端使用的是Hibernate4/Spring3。我正在使用Spring提供的过滤器,以便在DAO的save方法中findByID之后可以持久化集合。我的问题是,当子集合基于列表时,一切似乎都正常工作,但当它们基于集合时,并不是来自客户端的所有项都能顺利到达服务器 我的代码如下所示: Set <IProposalTemplateProxy> newList = getElementsF

我对RequestFactory有一个小问题,关于以集合的形式持久化子集合。我使用的是2.5,后端使用的是Hibernate4/Spring3。我正在使用Spring提供的过滤器,以便在DAO的save方法中findByID之后可以持久化集合。我的问题是,当子集合基于列表时,一切似乎都正常工作,但当它们基于集合时,并不是来自客户端的所有项都能顺利到达服务器

我的代码如下所示:

   Set <IProposalTemplateProxy> newList = getElementsFromUiSomehow (); //these elements can be new or just the old ones with some changes
   indicationTemplate.getProposalTemplates ().clear ();
   indicationTemplate.getProposalTemplates ().addAll (newList);
-根实体指示模板:

@Entity
@Table (name = "vdasIndicationTemplate")
@org.hibernate.annotations.Table ( appliesTo = "vdasIndicationTemplate", indexes = 
               {@Index (name = "xieIndicationTemplateCreateUser", columnNames= {"createUserID"}),
               @Index (name = "xieIndicationTemplateModifyUser", columnNames= {"modifyUserID"})})
public class IndicationTemplate extends AbstractEditable <Integer> implements IEntity <Integer>, IDateable, IDescriptable {
//...
   private Set <ProposalTemplate> proposalTemplates = null;
//...
   @OneToMany (fetch = FetchType.LAZY, mappedBy = "indicationTemplate"
         , cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH, CascadeType.DETACH})
   public Set <ProposalTemplate> getProposalTemplates () {
      return proposalTemplates;
   }
   public void setProposalTemplates (Set <ProposalTemplate> proposalTemplates) {
      this.proposalTemplates = proposalTemplates;
   }
//...
}
@实体
@表(name=“vdasIndicationTemplate”)
@org.hibernate.annotations.Table(appliesTo=“vdasIndicationTemplate”,索引=
{@Index(name=“xieIndicationTemplateCreateUser”,columnNames={“createUserID”}),
@索引(name=“xieIndicationTemplateModifyUser”,columnNames={“modifyUserID”})
公共类指示模板扩展了抽象性、可识别性和可识别性{
//...
私有集合proposalTemplates=null;
//...
@OneToMany(fetch=FetchType.LAZY,mappedBy=“指示模板”
,cascade={CascadeType.MERGE,CascadeType.PERSIST,CascadeType.REFRESH,CascadeType.DETACH})
公共集getProposalTemplates(){
返回提议模板;
}
公共无效设置proposalTemplates(设置proposalTemplates){
this.proposalTemplates=proposalTemplates;
}
//...
}
-子实体ProposalTemplate当然具有相反的多通映射,并且具有3个子集合以及具有3个不同实体的相同类别

-根实体的客户端代理:

@ProxyFor (value = IndicationTemplate.class, locator = PersistenceEntityLocator.class)
public interface IIndicationTemplateProxy extends IEntityProxy, IDeletableProxy, IDescriptableProxy {
//....
   Set <IProposalTemplateProxy> getProposalTemplates ();
   void setProposalTemplates (Set <IProposalTemplateProxy> proposalTemplateProxy);
}
@ProxyFor(value=IndicationTemplate.class,locator=PersistenceEntityLocator.class)
公共接口IIIndicationTemplateProxy扩展了IEntityProxy、IDeletableProxy、IDescriptableProxy{
//....
设置getProposalTemplates();
作废setProposalTemplates(设置proposalTemplateProxy);
}
-在客户端上,我呈现根实体的属性以及子实体的列表。然后,用户可以对其进行更新,并将更改存储回集合,如下所示:

   Set <IProposalTemplateProxy> newList = getElementsFromUiSomehow (); //these elements can be new or just the old ones with some changes
   indicationTemplate.getProposalTemplates ().clear ();
   indicationTemplate.getProposalTemplates ().addAll (newList);
Set newList=getElementsFromUiSomehow()//这些元素可以是新的,也可以只是经过一些更改的旧元素
indicationTemplate.getProposalTemplates().clear();
indicationTemplate.getProposalTemplates().addAll(新列表);
-然后在某个时刻:

   requestContext.saveIndicationTemplate ((IIndicationTemplateProxy) entityProxy)
                                          .fire (new Receiver <IIndicationTemplateProxy> () 
requestContext.saveIndicationTemplate((IIndicationTemplateProxy)entityProxy)
.火灾(新接收器()
-RequestContext看起来像:

@Service (value = TemplateService.class, locator = SpringServiceLocator.class)
public interface ITemplateRequestContext extends RequestContext {
   /** saves (creates or updates) one given indication template */
   Request <IIndicationTemplateProxy> saveIndicationTemplate (IIndicationTemplateProxy indicationTemplate);
//....
}
@Service(value=TemplateService.class,locator=SpringServiceLocator.class)
公共接口ITemplateRequestContext扩展了RequestContext{
/**保存(创建或更新)一个给定的指示模板*/
请求saveIndicationTemplate(IIIndicationTemplateProxy indicationTemplate);
//....
}
问题是每个请求只向集合服务器端添加了1个子实体。例如,indicationTemplate有2个proposalTemplates,我又添加了4个,那么在服务器端saveIndicationTemplate上,该实体只包含3个而不是6个。如果发生这种情况,无论我以前有多少个实体,也不管我添加了多少个,我只会再获得1个than之前在服务器上。我确实在启动requestContext方法之前检查了代理对象,它和它的所有子对象都已完全加载。最后,最奇怪的是,如果我替换Set per List(以及所有后续更改),一切都正常

在使用集合而不是列表时,RF无法将所有更改传输到服务器,这可能会有任何问题吗?顺便说一句,在这种情况下,我确实更喜欢集合,所以这就是我提出问题的原因

有人吗


谢谢您的帮助!

我想您遇到了这个错误。这是一个已知的gwt错误,尚未修复


尝试使用列表而不是集合,这应该很好。

有一个与集合
ValueProxy
s相关的集合,但没有任何相关。
EntityProxy
s。非常感谢Thomas的回答。看起来几乎是同一个问题,尽管评论中的一些人说EntityProxy与集合一起工作……但它可能与diff有关不同的GWT版本?所以,我知道目前唯一的解决方案似乎是使用列表而不是集合。这并不是说我喜欢这个想法,但可能我就是这么做的。