Problem with MarkupBuilder

248 views
Skip to first unread message

Sascha Pfau

unread,
Dec 5, 2015, 6:04:30 AM12/5/15
to jooq...@googlegroups.com

Hello Lukas,

 

i've some troubles with configuration generation for jooq codegen. The generation of daos and pojos should be enabled. So the XML should look like this:

 

-- snip --

</jdbc>
 <generator>
   <database>
     <includes>.*</includes>
     <inputSchema>XXX</inputSchema>
   </database>

</generate>
    <pojos>true</pojos>

<daos>true</daos>
   </generate>

<target>
-- snip --

 

This is the builder i've used:

 

def xml = new groovy.xml.MarkupBuilder(writer)

.configuration('xmlns': 'http://www.jooq.org/xsd/jooq-codegen-3.7.0.xsd') {

jdbc() {

driver('com.mysql.jdbc.Driver')

url('jdbc:mysql://server:3306/database')

user('test')

password('test')

}

generator() {

name('org.jooq.util.DefaultGenerator')

database() {

name('org.jooq.util.mysql.MySQLDatabase')

includes('.*')

inputSchema('XXX')

}

generate() {

pojos true

daos true

}

target() {

packageName('de.XXX')

directory('src/db')

}

}

}

 

But the MarkupBuilder creates always the following wrong XML code

 

<configuration xmlns='http://www.jooq.org/xsd/jooq-codegen-3.7.0.xsd'>
 <jdbc>
   <driver>com.mysql.jdbc.Driver</driver>
   <url>jdbc:mysql://server:3306/database</url>
   <user>test</user>
   <password>test</password>
 </jdbc>
 <generator>
   <database>
     <includes>.*</includes>
     <inputSchema>XXX</inputSchema>
   </database>
   <pojos>true</pojos>

<daos>true</daos>
   <target>
     <packageName>de.XXX</packageName>
     <directory>src/db</directory>
   </target>
 </generator>
</configuration>

 

pojos and daos are not enclosed by generator tag and so the code generation ignore it and does not create any pojos or daos. Any hints what's wrong?

 

Cheers

MrPeacock

signature.asc

Lukas Eder

unread,
Dec 5, 2015, 7:22:38 AM12/5/15
to jooq...@googlegroups.com
Hi Sascha,

From a high level, I'd say you're missing parentheses. You wrote:

generate() {

    pojos true

    daos true

}


I think it should be

generate() {

    pojos(true)

    daos(true)

}


But I'm rather inexperienced with Groovy's MarkupBuilder. Perhaps I'm missing something else. You might get a better answer on Stack Overflow for this...

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+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sascha Pfau

unread,
Dec 5, 2015, 7:51:06 AM12/5/15
to jooq...@googlegroups.com

Hi Lukas,

 

after some googleling i've found this on stackoverflow

 

http://stackoverflow.com/questions/11388838/groovy-markupbuilder-name-conflict/11389034#11389034

 

if i change the groovy code to...

 

generate([:]) {

pojos true

daos true

}

 

... the created XML is correct and pojos were created. I don't know what's going on behind the scenes. But it works for me now.

 

Cheers

Sascha

signature.asc

Lukas Eder

unread,
Dec 5, 2015, 7:53:56 AM12/5/15
to jooq...@googlegroups.com
Interesting, good to know.

Well, or perhaps, just fall back to good old XML where there's no magic going on :-)
Reply all
Reply to author
Forward
0 new messages