Hi Janne,
Thanks very much for your interesting questions. Disclaimer here is that
we're entering "opinion land" very deeply. There isn't really a truly
correct approach at separating concerns in these areas, only approximations
with tradeoffs. For instance, the tradeoff of not "leaking" jOOQ's
UpdatableRecords ("ActiveRecords") outside of a "repository" is that you're
losing record lifecycle information (i.e. what record attributes have
really changed). But that might be perfectly fine in your case.
What particular parts of Spring Data's core / commons "magic" are you
looking into reusing?
As far as CRUD and mapping is concerned, jOOQ ships with a
DefaultRecordMapper [1], which is applied automatically when calling
Record.into(Class) or Result.into(Class). Michael Simons has written an
interesting blog post [2] about how to enhance jOOQ's default behaviour for
more complex mapping.
You can also use jOOQ's DAO feature, which to some extent competes with /
replaces Spring Data's repositories [3]. They implement a lot of CRUD
convenience - although, with no magic.
Of course, as your domain objects don't map 1:1 to tables, you will
probably want to follow an approach similar to Michael Simons's approach.
I hope this helps. If you have any additional questions about any details
of the above, please do ask and I'll be very happy to help.
Cheers,
Lukas
[1]:
http://www.jooq.org/javadoc/latest/org/jooq/impl/DefaultRecordMapper.html
[2]:
http://info.michael-simons.eu/2015/09/09/jooq-and-spring-manage-your-recordmappers-as-components
[3]: http://www.jooq.org/doc/latest/manual/sql-execution/daos
2016-09-06 16:29 GMT+02:00 Janne Hyötylä <[email protected]>:
> Hello,
>
> We are starting a new project based on Spring Boot and have selected jOOQ
> as our main DB querying framework.
>
> Does anybody have experiences with Spring and jOOQ? None of our devs have
> used jOOQ so far, so I'm looking for best practices and possible pitfalls.
>
> Since Spring Boot already has a sensible autoconfiguration for jOOQ, that
> is not an issue. I'm rather looking for infos on:
>
> * Integration with Spring Data? Is that possible? Can we reuse some of the
> Spring Data repository "magic" to reduce boilerplate? I'm not talking about
> Spring Data JPA but rather the "core" (or commons), since we at first try
> to avoid JPA completely.
>
> * What are the mechanisms that can help us with CRUD and domain mapping?
> We don't have too many tables and only a few simple CRUD operations (the
> larger portion being complex queries and data transformations), but for
> those cases, which patterns would be useful?
> I wouldn't like to leak the jOOQ ActiveRecord objects above the repository
> layer, since I think the consensus is that mixing ActiveRecord and business
> logic leads to difficult-to-maintain code. And because our domain objects
> don't necessarily map 1:1 to tables, jOOQs POJO or DAO autogeneration might
> not produce the best results.
>
>
> Thanks in advance for any insights!
>
> Best,
> Janne
>
> --
> 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.
>
--
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.