2013-01-16 2 views
3

Set 모양의 하위 모음의 지속성과 관련하여 RequestFactory에 약간의 문제가 있습니다. 2.5와 , 그리고 백엔드에서 Hibernate4/Spring3을 사용하고 있습니다. 나는 봄에 의해 필터를 사용하고 있으므로, 나의 DAO의 save 메소드에서 findByID 뒤에 콜렉션을 지속시킬 수있다. 내 문제는 어린이 컬렉션이 List를 기반으로 할 때 모든 것이 정상적으로 작동하는 것으로 보이지만 Set에 기반 할 때 클라이언트의 모든 항목이 서버에 실제로 도달하지는 않습니다.Set 하위 모음이있는 GWT RequestFactory

내 코드는 다음과 같습니다

년 - 루트 개체 IndicationTemplate : 물론

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

년 - 아이 엔티티 ProposalTemplate 반대 ManyToOne 매핑을 가지고 있으며, 3 하위 컬렉션뿐만 아니라 같은있다 3 개의 엔티티로 정렬. 루트 개체에 대한

-client 측 프록시 : 클라이언트 -On

@ProxyFor (value = IndicationTemplate.class, locator = PersistenceEntityLocator.class) 
public interface IIndicationTemplateProxy extends IEntityProxy, IDeletableProxy, IDescriptableProxy { 
//.... 
    Set <IProposalTemplateProxy> getProposalTemplates(); 
    void setProposalTemplates (Set <IProposalTemplateProxy> 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); 

- 그리고 다음 몇 가지 점에서 :

:

requestContext.saveIndicationTemplate ((IIndicationTemplateProxy) entityProxy) 
              .fire (new Receiver <IIndicationTemplateProxy>() 

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

요청 당 하나의 하위 엔터티 만 컬렉션 서버쪽에 추가됩니다. 예를 들어, indicationTemplate에는 2 개의 proposalTemplates가 있고, 4를 더 추가 한 다음 서버 측 saveIndicationTemplate에 엔티티가 6 대신 3 개만 포함됩니다. 이전 엔 엔티티의 수와 항목 수에 관계없이 1이됩니다. 이전보다 서버에서. 나는 requestContext 메소드를 실행하기 직전에 프록시 객체를 체크했는데, 그것의 모든 자식들과 함께 완전히로드되었다. 마지막으로 가장 이상한 일은 Set per List (그리고 모든 후속 변경 사항)을 대체하면 모든 것이 효과적입니다!

목록 대신 집합을 사용할 때 RF가 서버에 대한 모든 변경 사항을 전송하지 못하는 문제가있을 수 있습니다. Btw, 나는이 경우 세트를 선호한다. 그래서 내가 묻는 것이다.

누구?

도와 주셔서 감사합니다.

+1

[커플] (https://code.google.com/p/google-web-toolkit/issues/detail?id=7025) [issues] (https://code.google.com/ p/google-web-toolkit/issues/detail? id = 6354)'ValueProxy'의 세트와 관련이 있습니다. 'EntityProxy'입니다. –

+0

답변 해 주신 Tom에게 감사드립니다. 주석에있는 일부 사람들은 Set과 함께 EntityProxies가 작동하지만 ... 다른 GWT 버전이있을 수 있지만 거의 같은 문제인 것처럼 보입니다.그래서, 지금은 Set 대신 List를 사용하는 것이 유일한 해결책이라고 생각합니다. 내가 그 생각을 좋아하지는 않지만, 나는 그저 그렇게 할 수 있습니다. –

답변