Well, I do this:
Code:
Session dom4jSession = session.getSession(EntityMode.DOM4J);
then, I'd do something like this:
Code:
List theList = dom4jSession.createQuery("from MyClass myclass where myclass.someDate = ?).setDate(0, theDate).list()
This will give me a list of Dom4J Elements. Then I take these Elements, and add them to another Element, which resides inside of a Dom4j Document.
Then, once I've built up this Document, I create an OutputFormat, and an XMLWriter, and write it to a ByteArrayOutputStream. With the current mapping file as described, "someDate" would be a node in every "Myclass" Element. But I don't want to include that in the output. For the query, I need to do a "where" clause with the date, but I don't want it to see the date in the results.
So, the only way I can think of to do this, is to loop through all of the results, (which in this case are Dom4j Elements) and remove the "someDate" nodes, so when the XML gets flattened, the "someDate" fields don't show up.
I'd like to avoid this if I can. The code in here is just a sample to demonstrate what I'm trying to do. In reality, I want to omit a few columns from the XML output, but apply a "where" clause on them, to get the data desired.
Thanks,
-Dan.