如何提出要求工厂非运输型可运输?

时间:2013-07-01 23:28:36

标签: gwt gis geospatial requestfactory hibernate-spatial

根据这个答案:Is com.vividsolutions.jts.geom.Geometry directly transportable using requestfactory?几何是(一种类型的特殊情况)使用requestfactory无法运输。

那么这会有用吗? :

@Entity
public class Poi  {


    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Id
    private Integer id;

    @Type(type="org.hibernate.spatial.GeometryType")
    private Geometry geom;


    //bi-directional many-to-one association to PoiCateg
    @ManyToOne
    @JoinColumn(name="id_cat")
    private PoiCateg poiCateg;

    @Version
    private Integer version;

    public Poi() {
    }

    public Integer getId() {
        return this.id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Geometry getGeom() {
        return this.geom;
    }

    public void setGeom(Geometry geom) {
        this.geom = geom;
    }


    public PoiCateg getPoiCateg() {
        return this.poiCateg;
    }

    public void setPoiCateg(PoiCateg poiCateg) {
        this.poiCateg = poiCateg;
    }

//not your standard getters and setters

public String getGeomClient() {
        return //result of method that converts from Geometry object to WKT string representation 
    }

    public void setGeomClient(String geom) {
        this.geom = // result of method that converts from String to Geometry
    }
}

然后我修改的Poi实体代理看起来像:

@ProxyFor(value=Poi.class)
public interface PoiProxy implements EntityProxy {

    public Integer getId() ;

    public void setId(Integer id);

    public PoiCategEntityProxy getPoiCateg() ;

    public void setPoiCateg(PoiCateg poiCateg);

//not your standard getters and setters

    public String getGeomClient() ;

    public void setGeomClient(String geom) ;
}

因为服务器实体中的getGeomClient和setGeomClient包含几何类型,所以客户端会出现问题吗?

EDIT1:忘了@Version私有整数版;错误修复。

1 个答案:

答案 0 :(得分:2)

它不仅可以工作,而且是(最简单)使其工作的方式。

替代方案涉及使用包装器/构建器。我也看到有人使用EntityProxy s将字符串化的值用作标识符,但要注意RequestFactory requires a per-request cache