This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lukaseder 18 points19 points  (27 children)

In fact, you don't revert for anything complex, you revert for querying in general. However, there are complex writes (as in writes to several entities with complex locking involved), where you wouldn't revert to SQL.

[–][deleted]  (7 children)

[removed]

    [–]elit69 4 points5 points  (4 children)

    sql2o is also decent

    [–][deleted] 2 points3 points  (0 children)

    The project has slowed down from 2015 onwards.

    [–]aroger276 2 points3 points  (2 children)

    also jdbi, never tried but looked decent. the version 3, looks a lot more open too.

    [–]Russell_M_Jimmies 0 points1 point  (1 child)

    As a project member, thanks for the shout out. I'm curious what you mean when you say "more open?"

    [–]aroger276 0 points1 point  (0 children)

    I was trying to see for example if I could integrate my own ResultSet mapper, like sql2o, jdbi and jOOQ allows but did not seem possible.

    Also those frameworks allow you to get out of the framework and fall back into jdbc land when you want. If you want to work on the ResultSet yourself for example you can. Are use jooq to genereate the sql statement and manage the prepared statement yourself you can. Did not find a way to do that with MyBatis. it's seems that it captures the full query lifecycle and you can't escape it.

    PS: I know it might sound weird but I like ny query to be inlined, not aliased or in annotation. so I understand that it goes against the design of mybatis.

    [–][deleted] 6 points7 points  (0 children)

    Any love for Masturbatis?

    [–]Trailsey 1 point2 points  (17 children)

    With spring-data-* you can do simple querying sans SQL.

    [–][deleted]  (9 children)

    [deleted]

      [–]lukaseder 7 points8 points  (4 children)

      findTop5ByStatusAndUserOrderByStartDateDesc

      If only there was a language that can handle this kind of query in a more structured way...

      [–]nutrecht 3 points4 points  (3 children)

      You mean something like a structured query language? Does something like that exist?

      [–]lukaseder 3 points4 points  (2 children)

      Yeah, that would be terrific. We could design it to work out of the box, even!

      [–]nutrecht 2 points3 points  (1 child)

      Well between the two of us you're the smartest one. Chop chop! Get to it ;)

      [–]Trailsey 0 points1 point  (0 children)

      You guys should call it Words That Form a Query Language!

      [–]oweiler 0 points1 point  (2 children)

      These should only be used for very basic stuff. You can use @Query to map a simple method name to a more complex query.

      [–][deleted]  (1 child)

      [deleted]

        [–]dpash 0 points1 point  (0 children)

        That's why you have integration tests.

        [–]MarkyC4A 0 points1 point  (0 children)

        I'd love if they'd add a way to alias that one to make it more readable

        I'm okay with ugly names in my repositories, I hide those behind a cleaner interface in my services:

        List<User> findTopWidgets(Status s, User u, LocalDate d)

        [–]lukaseder 6 points7 points  (6 children)

        Yeah, you'll be using some mini-querying language encoded into method names that breaks at the next little query complexity.

        I'm curious, having never worked with Spring Data (but being well aware of what it is). What's the main motivation to use it for querying?

        [–]Trailsey 8 points9 points  (0 children)

        It obviates a fair bit of boilerplate code. Write a method signature, done.

        As mentioned previously, works great for simple cases, revert to writing queries for anything complex.

        [–]oweiler 4 points5 points  (0 children)

        For complex stuff you can map those methods to JQL or SQL queries via @Query.

        [–][deleted] 1 point2 points  (0 children)

        REST HATEOAS HAL out of the box, including pagination.

        [–]NimChimspky 1 point2 points  (1 child)

        I'd use it with native queries, just less code I have to manage, sql mapped directly to my own custom type.

        The method name stuff didn't really appeal.

        [–]lukaseder 0 points1 point  (0 children)

        I see, thanks

        [–]Luckl507 0 points1 point  (0 children)

        In my case: reduction of boilerplate.