1

根据这个答案:com.vividsolutions.jts.geom.Geometry 是否可以使用 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 private Integer 版本;错误已修复。

4

1 回答 1

2

它不仅会起作用,而且是使它起作用的(最简单的)方法。

替代方案涉及使用包装器/构建器。我还看到人们使用EntityProxys ,其中字符串化的值用作标识符,但要注意RequestFactory 需要每个请求的缓存

于 2013-07-02T00:26:48.337 回答