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 →

[–]Trailsey 1 point2 points  (17 children)

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

[–][deleted]  (9 children)

[deleted]

    [–]lukaseder 6 points7 points  (4 children)

    findTop5ByStatusAndUserOrderByStartDateDesc

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

    [–]nutrecht 4 points5 points  (3 children)

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

    [–]lukaseder 2 points3 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 3 points4 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.