Separate name between Tables and Pojos

467 views
Skip to first unread message

Agharta agharta

unread,
Mar 20, 2012, 11:37:29 AM3/20/12
to jOOQ User Group
Hi again,

A suggestion: because tables names and pojos class names are the same
(TABLE NAME = Customer.java, POJO NAME = Customer.java), a suffix in
Table classes or Pojo classes is suggested.

As records (CustomerRecord.java), i suggest to modify pojo base class
name. Example CustomerObject.java or whatever you want.

This is suggested because, if i use pojo classes and table classes in
same file, one of they is fully referenced in code (not beautiful to
see) and not easy to see and manage (possibility to confuse names
during code typing).

I can suggest a parameter into code generator xml

<generate>
......
<pojos>true</pojos>
<pojos-suffix-name>Object</pojos-suffix-name>
......
</generate>



Thank you again.

Best regards,

Agharta

Lukas Eder

unread,
Mar 20, 2012, 11:44:22 AM3/20/12
to jooq...@googlegroups.com
Hello Agharta,

Please consider this section from the manual:
http://www.jooq.org/manual/META/AdvancedConfiguration/

It explains how you can customize generated artefacts.

Cheers
Lukas

2012/3/20 Agharta agharta <agha...@gmail.com>:

Agharta agharta

unread,
Mar 20, 2012, 12:53:11 PM3/20/12
to jooq...@googlegroups.com
Hi,
thank you!

I've see the code, you're right, but....

I think that is my mistake but i've extended DefaultGeneratorStrategy like this.

....blablabla...


/**
     * Override this method to define how your Java classes and Java files
     * should be named. This example applies no custom setting and uses
     * CamelCase versions instead
     */
    @Override
    public String getJavaClassName(Definition definition, Mode mode) {
        String str = super.getJavaClassName(definition, mode);
        if (mode == Mode.POJO) {
            str += "Pojo";
        }
        return str;

    }


----bla bla bla------


i've see the generated code and the pojo java name is xxxPojo.java, right. But the class name definition into the file remains the old one (without "Pojo" suffix).

I've see the class DefaultGenerator and - at row 810 - it uses

out.print(strategy.getJavaClassName(table))

without Mode parameter. It calls GeneratorStrategyWrapper, not my CustomGeneratorStartegy.

Is it right? If yes, could you explain me how to set my custom name into code-class definition?

Thank you again and sorry for my stupid questions.

Agharta


 




Il giorno martedì 20 marzo 2012 16:44:22 UTC+1, Lukas Eder ha scritto:
Hello Agharta,

Please consider this section from the manual:
http://www.jooq.org/manual/META/AdvancedConfiguration/

It explains how you can customize generated artefacts.

Cheers
Lukas

2012/3/20 Agharta agharta

Lukas Eder

unread,
Mar 20, 2012, 1:06:50 PM3/20/12
to jooq...@googlegroups.com
Hello again,

> I've see the class DefaultGenerator and - at row 810 - it uses

You've discovered a bug at precisely that location. I'll file this as #1244:
https://sourceforge.net/apps/trac/jooq/ticket/1244

This will be fixed ASAP. Thanks for reporting this.

> without Mode parameter. It calls GeneratorStrategyWrapper, not my
> CustomGeneratorStartegy.
>
> Is it right? If yes, could you explain me how to set my custom name into
> code-class definition?

This is correct. The GeneratorStrategyWrapper is there to protect you
from common code-generation flaws. It implements
- method name disambiguation when tables have the same name as one of
their columns, like TABLE.TABLE
- method name disambiguation when getters are already present in the
class hierarchy, like TABLE.CLASS, which would generate an illegal
"getClass()" method.
- field name disambiguation when fields have the same name as Java
keywords, like TABLE.PUBLIC, which would generate an illegal "public"
field.

The GeneratorStrategyWrapper will ultimately call your own custom
strategy, though.

Cheers
Lukas

Lukas Eder

unread,
Mar 20, 2012, 2:29:07 PM3/20/12
to jooq...@googlegroups.com
>> I've see the class DefaultGenerator and - at row 810 - it uses
>
> You've discovered a bug at precisely that location. I'll file this as #1244:
> https://sourceforge.net/apps/trac/jooq/ticket/1244
>
> This will be fixed ASAP. Thanks for reporting this.

Fixed on SVN trunk and GitHub

Agharta agharta

unread,
Mar 20, 2012, 3:44:55 PM3/20/12
to jooq...@googlegroups.com
Hi,
Many thanks for your quick fix!

I'm happy to have helped you to discover this bug!
I'm going to see your modified code.

Another suggestion: what do you think about a nightly unstable build with not already released fixes/features?
Or a continuos build like this: http://deadlock.netbeans.org/hudson/  for example.

In this way, any user can download an unstable build to test it, without recompile it by hand. (i known, i'm a lazy man....  )

Thank you again for your great work.

Best regards,

Agharta

Lukas Eder

unread,
Mar 20, 2012, 5:10:58 PM3/20/12
to jooq...@googlegroups.com
Hello Agharta,

> Another suggestion: what do you think about a nightly unstable build with
> not already released fixes/features?
> Or a continuos build like this: http://deadlock.netbeans.org/hudson/ for
> example.

I release unfrequent SNAPSHOT releases on the Sonatype Maven repository here:
https://oss.sonatype.org/content/repositories/snapshots/org/jooq/

Surely, Hudson/Jenkins would be a nice tool for automation. Do you
happen to know any hosting service for automated builds? It would be a
great plus if I could even run some of the integration tests, at least
those involving open source databases, such as Postgres, MySQL,
HSQLDB, H2, and Derby

> In this way, any user can download an unstable build to test it, without
> recompile it by hand. (i known, i'm a lazy man....  )

We're all lazy. I'd profit from automation just as much as you! :-)

Cheers
Lukas

Agharta agharta

unread,
Mar 21, 2012, 3:22:54 AM3/21/12
to jooq...@googlegroups.com
Hello Lukas,



We're all lazy. I'd profit from automation just as much as you! :-)

Ah ah ah! You're right!!!! We're all lazy! Evolution cause??? :-)



Surely, Hudson/Jenkins would be a nice tool for automation. Do you
happen to know any hosting service for automated builds?

I use hudson in my internal server, it works very well.

With plugins you can upload the snapshot builds into a ftp directory or via maven repository, or in other many way.

Searching with google i've found these hostings:

http://jenkinshosting.com/    (free for open sourced projects and unlimited users, it seems very complete)

http://www.cloudbees.com/   (it seems a pay per service hosting)

Glad to help you,

cheers,

Agharta
Reply all
Reply to author
Forward
0 new messages