Hibernate version: 3.0
Some tables in my database contain binary data. So, in my configuration file, you might find something like:
Code:
<property name="binarydata" column="BinaryData" node="BinaryData" type="binary" not-null="true" />
In my class, I have a field named "BinaryData", which is a "byte[]" This receives the bytes properly, and everything is fine.
But I also need to turn my class into an XML document. So, I create a session, with the entity-mode set to DOM4J.
Code:
Session session = IPSSessionFactory.currentSession();
Session dom4jSession = session.getSession(EntityMode.DOM4J);
// insert Document creating code, queries, etc.
Element elt = dom4jSession.createQuery("from someTable").uniqueResult();
Then I use the Dom4J stuff to create an XMLWriter, and all of the XML gets output just as I'd expect. Except that the binary field (as byte[]) gets generated as the hex-value of the bytes. What I'd really like to do is have that field export the base64 representation of those bytes, and I'm not sure the best way to do this.
Any help in this would be greatly appreciated.
Thanks,
-Dan.