views:

53

answers:

2

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)

+1  A: 

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.

Robert Munteanu
I agree, and disagree. Decoupling is fine, as long as it does not requires much extra work. I don't think the implementation will change from Hibernate and java. Why create another abstraction layer just for nothing?"Hibernate is a way of life" - so it is no easy to get rid of it...
pihentagy
I meant to say that the client is coupled on Hibernate, which might not be what you want. You have a web service which in theory is client platform agnostic, but in practice is bound to java and hibernate. Perhaps you're better off using something like RMI if you're all java.
Robert Munteanu
A: 

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.

dma_k