Hi
I'm using a combination of JAX-WS and Hibernate.
It works quite well,but I can't quite handle the session correctly.
The problem is, if I close the session, before I exit the WebService method, as I should,
Hibernate throws an Exception when JAX-WS tries to serialize the Object
+ its children.The object has been read from the database, but the child/children are still in the Hibernate buffer/Database.
Therefore by closing the associated session, I take away any chance JAX-WS has to serialize the objects.
How does one go about solving this problem?
Code:
@WebMethod
public Collection<Something> getSomething () throws Exception
{
//The Hibernate Session gives the object without changes.
Session session = getSession();
Query query = session.createQuery("from Something");
Collection <Something> collectionWithChildren = (Collection<Something>)query.list();
session.close
return collectionWithChildren;//throws an Exception when serializing children.
}
Thanks in advance for you suggestions.