How to generate camel-named POJO with camel-named schema

28 views
Skip to first unread message

Goddamned Qu

unread,
Jul 14, 2016, 6:13:53 AM7/14/16
to jOOQ User Group
hi

with the camel-named schema :

CREATE TABLE `Author` (
  `id` int NOT NULL,
  `firstName` varchar(255) DEFAULT NULL,
  `lastName` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
);

the generated POJO would be like this:

public class Author {
    private Integer id;
    private String  firstname;
    private String  lastname;

    public String getFirstname() {
        return this.firstname;
    }
    public Author setFirstname(String firstname) {
        this.firstname = firstname;
        return this;
    }
    // omit some code ...
}

how could I make the POJO camel-named as well


<strategy>
<matchers>
<fields>
<field>
<expression>^(.)(.+)$</expression>
<fieldMember>
<transform>AS_IS</transform>
<expression>$0</expression>
</fieldMember>
<fieldSetter>
<transform>AS_IS</transform>
<expression>set$0</expression>
</fieldSetter>
<fieldGetter>
<transform>AS_IS</transform>
<expression>get$0</expression>
</fieldGetter>
</field>
</fields>
</matchers>
</strategy>


but got setters like this `setfirstName`

Is there a way to do this besides modify MatcherStrategy.java like this 

     private final String transform(String string, MatcherTransformType transform) {
        if (transform == null)
            return string;

        switch (transform) {
            case AS_IS:
                return string;
           ...
           case CAPITALIZE:
              return StringUtils.Capitalize(string);


Am I missing sth.? thanks

Lukas Eder

unread,
Jul 14, 2016, 11:21:07 AM7/14/16
to jooq...@googlegroups.com
Hello,

Indeed, the AS_IS matcher transformation type is intended to produce setters like setLAST_NAME from columns like LAST_NAME. The idea is that case-sensitive searches across a code base will match.

Currently, your best option is to use programmatic strategies as documented here:

I wouldn't patch jOOQ's MatcherStrategy, unless you already wrote lots and lots of XML that you prefer not to migrate anymore...

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.

Goddamned Qu

unread,
Jul 14, 2016, 10:51:05 PM7/14/16
to jooq...@googlegroups.com
Got it, I will try it. thanks a lot!

--
You received this message because you are subscribed to a topic in the Google Groups "jOOQ User Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jooq-user/Nx23jqRfShA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jooq-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages