Code Monkey home page Code Monkey logo

Comments (1)

hylkevds avatar hylkevds commented on June 23, 2024

I've managed to create an implementation of the PersistenceManager that uses JOOQ instead of QueryDSL. It passes all our tests. Currently only long ids.

There are some interesting design differences between JOOQ and QueryDSL. The biggest difference is between the QueryDSL Expression and the JOOQ Field that both represent Columns, constants and other "expressions" in queries.

  • JOOQ's Field<DataType> is not sub classed and the default implementation is final.
  • QueryDSL's Expression is heavily sub classed: NumberExpression, ComparableExpression, etc.

As a result, in QueryDSL, the operations you can do on an Expression are determined by the specific interface that Expression implements. In JOOQ, all operations are defined in Field, so there is nothing stopping you from multiplying a Field<String> with a Field<Number>, and JOOQ will claim the result is a Field<String>.
The advantage of the JOOQ way is that if you have a Field type that JOOQ doesn't know, it is easy to make it work. For our use this type safety is not an issue, since our ExpressionHandler already makes sure things are correct.

Since Field can not really be sub classed, and our ExpressionHandler needs some way to pass our special Field types, I had to create a FieldWrapper interface with several implementations. In the end I think this is even cleaner than what I did in the QueryDSL back ends.

Another difference is that QueryDSL is very flexible in the order in which you add the different parts (join, where, from, etc) to the SQL query. JOOQ enforces a strict order, and you can't really have if statements in between, since every step returns a different interface. As a result I had to change the piecemeal way of building the query we used so far to a "first gather all data, then build the query in one go" approach. In itself also not a bad change.

I'll implement the other two ID types, and add the JOOQ back-end as a separate option to the master branch at first. After testing more thoroughly I may at some point replace the QueryDSL back-ends with the JOOQ versions.

from frost-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.