We have column names like "foo:bar"
I accidentally used jOOQ 3.1.0 to generate class names. I created a new ExampleRecord and called exampleRecord.Foo_bar() to set the "foo:bar" column. OK, that looks reasonable.
Then I tried to compile and ran into the problems that arise when mixing version numbers. So I updated the code generator to version 3.3.1 to match the library used in my code.
Now instead of exampleRecord.Foo_bar() I have to use exampleRecord.Foo_3abar(). (groan)
The source of the bug is easy to guess: somewhere the generator is URI-encoding encoding the column names (but why!??)
yielding "foo%3abar", so that when they get "cleaned up" and camelCased for Java this gets turned into "foo_3abar".
Ugh, this is just ugly. Could we get a patch release quickly that fixes this bug?
Otherwise we're going to have to have tons and tons of code that looks terrible, which will have to be updated when the bug is fixed.
(I'm just now going through and changing all my colleagues' JDBC code to jOOQ; this isn't going to help it sell well on my team.)
...
This is the general name mangling strategy to avoid conflicts when someone has all of foo:bar, foo_bar, and foo?bar columns. This was implemented in jOOQ 3.3.0:
...
Or your own programmatic strategies:
...
I'm aware that you've used the term "show-stopper" before for something that might have not appeared like a critical issue in ordinary contexts. I personally believe that this name-mangling scheme isn't such a critical issue.
On Sunday, April 27, 2014 11:44:26 PM UTC-7, Lukas Eder wrote:...This is the general name mangling strategy to avoid conflicts when someone has all of foo:bar, foo_bar, and foo?bar columns. This was implemented in jOOQ 3.3.0:
Hmmm... I empathize with the intent, but ... I'm not sure it should be the default behavior if ease-of-use is the goal. I'd imagine that the type of conflicts you mention are a tiny minority of cases. I'd recommend changing all invalid characters to '_' as you used to do, and allowing a simple flag for turning on/off illegal character URI-encoding.
...Or your own programmatic strategies:
Ooh, that looks promising! Thanks! I'll investigate that immediately.
...
Or your own programmatic strategies:
Ooh, that looks promising! Thanks! I'll investigate that immediately.
Yes, I think that would be the best way forward.
2014-04-28 15:35 GMT+02:00 Garret Wilson <gar...@globalmentor.com>:
On Sunday, April 27, 2014 11:44:26 PM UTC-7, Lukas Eder wrote:...This is the general name mangling strategy to avoid conflicts when someone has all of foo:bar, foo_bar, and foo?bar columns. This was implemented in jOOQ 3.3.0:
Hmmm... I empathize with the intent, but ... I'm not sure it should be the default behavior if ease-of-use is the goal. I'd imagine that the type of conflicts you mention are a tiny minority of cases. I'd recommend changing all invalid characters to '_' as you used to do, and allowing a simple flag for turning on/off illegal character URI-encoding.
I'll trade your tiny minority of people that produce collisions with special characters against my tiny minority of people who use special characters in object names more than very occasionally :-)
I think you grandly misinterpreted ...
--
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.
... your English is excellent. ...
Did you try "\" before the parentheses? (I'm not where I can test this right now)
A yes, but did you escape the escapes? "\\\"
On Monday, April 28, 2014 7:25:46 AM UTC-7, Lukas Eder wrote:...Or your own programmatic strategies:
Ooh, that looks promising! Thanks! I'll investigate that immediately.Yes, I think that would be the best way forward.
Hmmm... this is not working. I'm sure I'm doing something wrong. I just want to force the conversion of foo:bar to FOO_BAR (e.g. setFOO_BAR). So following the examples, I try:
<strategy>
<matchers>
<fields>
<expression>^(.+):(.+)$</expression>
<fieldIdentifier>
<transform>UPPER</transform>
<expression>$1_$2</expression>
</fieldIdentifier>
</fields>
</matchers>
</strategy>
That gives me an error: Cannot configure instance of org.jooq.util.jaxb.MatchersFieldType from ^(.+):(.+)$
...
I'm just checking... Have you upgraded everything to 3.3?
It looks as though the manual is not up to date after the fix in #2910.
...
But it doesn't give me what I want. With the changes you indicated, I still have an ugly ExampleRecord.setFoo_a3bar().
I don't find the manual very clear about the distinction among <fieldIdentifier>, <fieldMember>, <fieldSetter>, and <fieldGetter>. I had assumed that setting fieldIdentifier would automatically affect all the getters and setters for column names in records. This appears not to be the case. So how do I change field getters and setters? Do I need both a <fieldSetter> and <fieldGetter> section, both containing identical information? (Isn't it natural to think that a developers wants to use the same scheme for both getters and setters by default?) Or am I doing it wrong?
So it appears that the custom matcher strategies do not in fact allow one to work around the the forced URI-encoding of column names. Trying to reproduce getFoo_bar() (which is what jOOQ used to produce for a column named foo:bar) will in fact yield GETFOO_BAR() or GetFooBar(). The only way I can even make it work close to correctly is to use the AS_IS transform to yield getfoo_bar(). This is workable, but frustrating.
I would even go so far as to consider it bugs that the strategies require that "get" and "set" be provided in the output of <fieldSetter> and <fieldGetter>; and that the transform is applied to the "get" and "set" suffixes as well.
OK, I'll use what I got sort of working. But can someone tell me what <fieldMember> applies to?
/** * Override this method to define how Java members should be named. This is * used for POJOs and method arguments */ @Override public String getJavaMemberName(Definition definition, Mode mode) { return definition.getOutputName(); }
...
I would even go so far as to consider it bugs that the strategies require that "get" and "set" be provided in the output of <fieldSetter> and <fieldGetter>; and that the transform is applied to the "get" and "set" suffixes as well.
How would you go about people not wanting "get" and "set" in their getter and setter names?
OK, I'll use what I got sort of working. But can someone tell me what <fieldMember> applies to?It is used for member names in POJOs and also for method argument names.
I took Garret to mean that getters start with "get" and should not be part of the regexp replacement, not exposed to the uppercasing. Same for setters of course.
On Tuesday, April 29, 2014 12:21:49 AM UTC-7, Lukas Eder wrote:...I would even go so far as to consider it bugs that the strategies require that "get" and "set" be provided in the output of <fieldSetter> and <fieldGetter>; and that the transform is applied to the "get" and "set" suffixes as well.
How would you go about people not wanting "get" and "set" in their getter and setter names?
Um... er... as they say in Brazil, "estou sem palavras"---I'm without words. Speechless. hehe At first I thought you were joking. I mean, if the number of people using "foo:bar" and "foo#bar" in the same table is like .1% of users, a use who doesn't want "get" in the getter name (is it still a getter, then?) is like .05% of users. (Numbers used for explanatory value, not for accuracy.)
But this is very easily addressed, and at the same time addresses another issue I raised, namely that you shouldn't have to define both getters and setters when you know the general format of the property. jOOQ should add a property named <fieldProperty>. If defined, it determines what comes after both "get" and "set" in getters and setters, respectively. That is, if I set the <fieldProperty> transform to UPPER, then this produces getFOO() and setFOO() and I don't even have to define <fieldGetter> and <fieldSetter>. For that tiny fraction of people who don't even want "get" and "set" in their accessor names, then they can define <fieldGetter> and/or <fieldSetter>, which will override the rule in <fieldProperty> (or they don't even have to define <fieldProperty> at all). This solution therefore is even 100% backwards compatible. If you add it in the next version, no one even has to change their code if they want to continue using <fieldGetter> and/or <fieldSetter>!
See, the general rule should be, "make the default configuration work as expected for the 99.98% of normal use cases, and provide optional configuration for the .01% of users who want to break convention".
OK, I'll use what I got sort of working. But can someone tell me what <fieldMember> applies to?It is used for member names in POJOs and also for method argument names.
Maybe you could point me to an example? I guess I haven't got to POJOs yet---I was thinking the ExampleRecord class was like a POJO.
Anyway, Lukas, thanks so much for all your help and feedback on this. I've got jOOQ set up in our project now, and I've handed the database access part over to a teammate to convert some of our existing SQL to jOOQ. We'll see how it goes.
... Now. While you obviously don't agree with these arguments ...
On Tuesday, April 29, 2014 8:06:39 AM UTC-7, Lukas Eder wrote:... Now. While you obviously don't agree with these arguments ...Far from it! I've used ObjectPascal since back in the Borland Delphi 1.0 days, and its ability to define a property with separate accessor methods influenced the development of the same thing in C#. The "get" and "set" method pattern is clunky. Five minutes after waking up this morning I simply found it humorous that someone wanted to have a "getter" without "get".
My larger point is that the library should default to convention with the option for configuration, and I think my proposal for <fieldProperty> addresses that concern. Thanks for considering it! Have a productive day.