2015-10-27 9:46 GMT+01:00 <[email protected]>:

> So my first attempt was to create my own GeneratorStrategy and overwrite
>
>
>    - DefaultGeneratorStrategy.getJavaClassExtends(Definition, Mode)  (org.
>    jooq.util)
>
>
> but for some reason this does not get called for DAOs.
>

The original rationale is that most types (except for POJOs and jOOQ 3.8
domains) depend on an internal base implementation, e.g. TableImpl,
UpdatableRecordImpl, DAOImpl. In many of these cases, the base
implementation is required in jOOQ's internals. Thus far, we haven't seen
the need for changing that.

Of course, it might seem useful at first, as additional functionality can
be patched into generated classes very easily. But the effort to document
and maintain the additional requirements that evolve from this (e.g. your
"extends" class MUST extend DAOImpl, etc.) are a sign that we would be
creating too much complexity here.


> Even if this would have been possible, because setConfiguration is final,
> I wouldn't be able to overwrite and annotate the method. I agree it would
> have been the best to annotate the constructor, but there is no method in
> the JavaGenerator that I can overwrite. I've found
>
> if (generateSpringAnnotations())
>             out.println("@%s",
> out.ref("org.springframework.stereotype.Repository"));
>
> which adds an annotation to the constructor. Maybe this can be rewritten
> and extracted into a protected method writeConstructorAnnotations or
> something? I could then overwrite that method and add my annotations to
> inject the configuration via constructor so there is no need to remove the
> final keyword from setConfiguration.
>

That's correct. However (and I'm sorry if I sound like giving excuses all
the time), it is far from trivial to factor out *useful* code generation
extensions that are:

- Easy to document
- Obvious to discover
- Easy for us and you to maintain
- Forward-looking

There's a huge task in jOOQ 4.0 to improve (probably rewrite) the code
generator. Before that, I'm very wary of adding new features. It's probably
easier right now for you to just override the generateDao() method, and
roll your own.

Nonetheless, very good to hear feedback. Especially the DAO area is
apparently not good enough compared to what users need.


> Great (frame) work btw!
>

Thank you :)

-- 
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/d/optout.

Reply via email to