Question

Is there a way to pass a DetachedCriteria object to a jax-ws service?

(my problem is that DetachedCriteria does not have a no-arg constructor, which is required by jax-ws)

Was it helpful?

Solution

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.

You're better of creating some sort of Query object which mimics the Criteria:

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.

OTHER TIPS

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). That hardly doable :)

But you can serialize DetachedCriteria into stream of bytes via standard Java serialization mechanism and deserialize it on remote side. I agree, this approach is a mis-use of XML.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top