Hi Lukas,
while not forgetting from my previous posts that a customizable strategy
would be the ultimate(tm) solution I would still vote for additionally
adding a simple out-of-the-box naming strategy (explained below) into
jooq-codegen.
Let me explain the reason why:
- consider you use maven
- also consider that you mix jOOQ with something like *brrr* hibernate /
eclipselink / [any orm]
-> chances are very, very high that the class names of the entity classes
(e.g. Customer.java -> mapped to @Table "customer") will clash with the
jOOQ generated class 'Customer' when using the default strategy. This is
very(!) annoying and in order to avoid this you need a precompiled and
maven repository deployed module dependency with a custom naming strategy.
This is required since compilation is not available in the
"generate-sources" lifecycle of maven.
We currently use querydsl which prefixes all classes with 'Q'. We find that
quite pleasing since we can easily find all generated classes in the type
viewer of the IDE and practically no name clashes happen. Having a prefix
is simple but effective.
So I would suggest to bundle a very simple naming strategy in jooq-codegen
which would required very little space and maintenance but could probably
make like 95% of all people with name clashes happy. There will still be
people whining ("i want another prefix", "why not a suffix?" and such) but
still a high percentage of people would just appreciate not having this
darn name clashes. And then you can still have custom naming strategy.
I think avoiding name clashes overrules personal taste.
This would also make migration / integration of jOOQ into s$$t like
hibernate / orm much sexier and in the end make adaption of jOOQ easier :-)
-----------------------
please add me to 'jooq-codegen' :-)
-----------------------
package org.jooq.util;
/**
* variant of the default naming strategy {@DefaultGeneratorStrategy} adding
* the prefix 'J' to generated class names (e.g. to avoid name clashes
* with existing JPA entities and such)
*/
public class JPrefixGeneratorStrategy extends DefaultGeneratorStrategy {
@Override
public String getJavaClassName(final Definition definition, final Mode
mode) {
return 'J' + super.getJavaClassName(definition, mode);
}
}
-----------------------------
enabling it would be a simple matter of adding
<name>org.jooq.util.JPrefixGeneratorStrategy</name>
to pom.xml.
this class means practically zero maintenance effort but great relief for
maven / hibernate users...
Best regards
Peter
--
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.