How can I store XML data?

I saw How can I insert an XML document in PostgreSQL in Java? but I was wondering if jOOQ offers another solution to this kind of problem.

At the moment I don't see another method as to write something like

String sql = "INSERT INTO xml_docs(id, gkuzu) VALUES (?, XMLPARSE(?))";

and execute it with jOOQ

this.ctx.execute(sql);

but is there another option for more complex statements where I can also write e.g.

StringBuilder xml = new StringBuilder();

// ..

this.ctx.insertInto(MY_TABLE)
    .set(MY_TABLE.NAME, name)
    // ..
    .set(MY_TABLE.DESCRIPTION_XML, xml.toString());

or similar?

Answers


jOOQ 3.7 doesn't support XML (or JSON, etc.) types out of the box, but indeed, jOOQ helps you abstract the XML data type by implementing your custom data type binding. There's an example for JSON and PostgreSQL in the manual. You can adapt that easily for XML:

http://www.jooq.org/doc/latest/manual/sql-building/queryparts/custom-bindings

Essentially, you'll need to implement org.jooq.Binding<Object, YourXMLRepresentation>, and then configure the code generator to apply this binding either to all XML type columns, or to columns of a specific name pattern:

http://www.jooq.org/doc/latest/manual/code-generation/custom-data-type-bindings


Need Your Help

Making web form for updating data in Firebase

javascript jquery firebase

I am making an interface to manipulate data in Firebase. I managed to make a form that inserts new data, I have a list of retrieved data, the only thing that is missing is editing/updating existing...

Scrollbar on the text area inside powerpoint slide

powerpoint

I want to add a scroll bar inside a ppt slide. I have microsoft office 2007. I have searched and got that i have to add activex controls. Can someone provide full information.