[英]DetachedCriteria and jax-ws
Is there a way to pass a DetachedCriteria object to a jax-ws service? 有没有一种方法可以将DetachedCriteria对象传递给jax-ws服务?
(my problem is that DetachedCriteria does not have a no-arg constructor, which is required by jax-ws) (我的问题是DetachedCriteria没有jax-ws要求的无参数构造函数)
I would say ... please don't do that. 我会说...请不要那样做。
It's a shame to use something as decoupled as web services and then tie it to a specific Java+Hibernate combination, not to mention that and changes to your hibernate config will likely ripple through all the clients. 使用与Web服务解耦的东西然后将其绑定到特定的Java + Hibernate组合是可耻的,更不用说了,对Hibernate配置的更改可能会在所有客户端中泛滥成灾。
You're better of creating some sort of Query
object which mimics the Criteria
: 最好创建某种类似于
Criteria
的Query
对象:
public class Query {
public void setTargetClass(...) {}
public void addPropertyEquals(...) {}
/* more add/set instructions */
}
and then at the server side you have a class which converts the Query
to a Criteria
. 然后在服务器端有一个将
Query
转换为Criteria
。
JAXB is annotation-based, so you need to annotate DetachedCriteria
and all its subclassses before you can pass it via JAX-WS interfaces (on the top of requirement of no-arg constructor). JAXB是基于注释的,因此您需要先注释
DetachedCriteria
及其所有子类,然后才能通过JAX-WS接口(在无参数构造函数的要求之上)将其传递。 That hardly doable :) 那几乎是不可能的:)
But you can serialize DetachedCriteria
into stream of bytes via standard Java serialization mechanism and deserialize it on remote side. 但是,您可以通过标准Java序列化机制将
DetachedCriteria
序列化为字节流,并在远程将其反序列化。 I agree, this approach is a mis-use of XML. 我同意,这种方法是对XML的误用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.