JAXB Configuration

48 views
Skip to first unread message

eti...@studer.nu

unread,
Jan 16, 2018, 11:48:20 AM1/16/18
to jOOQ User Group
Hi Lukas

Would it be possible for you to generate the JAXB classes (Configuration, Jdbc, Generator, etc.) with an equals and hash code implementation? Not sure if the JAXB code generators provide such an option. It would allow the gradle-jooq-plugin to determine if the Configuration has changed between two runs.

Etienne

Lukas Eder

unread,
Jan 16, 2018, 12:00:25 PM1/16/18
to jooq...@googlegroups.com
Hi Etienne,

Thanks for your message.

Unfortunately, I'm not aware of any XJC plugins that implement equals() and hashCode() correctly without any external dependencies. But you can easily check for equality by serialising both Configuration objects to an XML string using 

boolean equal(Configuration c1, Configuration c2) {
  try {
    StringWriter w1 = new StringWriter();
    StringWriter w2 = new StringWriter();
    JAXB.marshal(c1, w1);
    JAXB.marshal(c2, w2);
    return w1.toString().equals(w2.toString());
  }
  catch (IOException ignore) {}
  return false;
}

I hope this helps,
Lukas

--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Lukas Eder

unread,
Jan 16, 2018, 12:01:22 PM1/16/18
to jooq...@googlegroups.com
... This of course depends on the javax.xml.bind module from JDK 9 onwards ;-)

Lukas Eder

unread,
Jan 16, 2018, 12:03:57 PM1/16/18
to jooq...@googlegroups.com
... I've added a feature request for this. Let's see if it's easy to write an XJC plugin:

Lukas Eder

unread,
Feb 16, 2018, 10:49:15 AM2/16/18
to jOOQ User Group
So, #7075 is now implemented for jOOQ 3.11 (will backport to 3.10.6). I must say, implementing an XJC plugin has been a rather interesting experience. Will blog about this soon, providing the source code for the plugin (still incredible that there seems to be no popular XJC plugin for this purpose!)
Reply all
Reply to author
Forward
0 new messages