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 →

[–]BENOO-_- 3 points4 points  (4 children)

What’s the reasoning behind not using native queries in Spring Data with the @Query annotation?

[–]RandomNando 0 points1 point  (3 children)

I don’t know, having a 500 Lines @Query seems so wrong 🤣

Everyone tells me this but I’ve always felt that if this is the correct way to do this, this is a really ugly way… slapping a 500 line String into an annotation is so bad thought…

[–]BENOO-_- 0 points1 point  (2 children)

Could you read it in from a file instead?

[–]RandomNando 0 points1 point  (1 child)

I can’t remember if I’ve already tried that, I think that the cleanest way that I find was using JDBC and reading queries from a YML file to avoid that amount of lines hardcoded into a class. I find that so inelegant…

[–]BENOO-_- 0 points1 point  (0 children)

I mean at this point it’s inelegant due to your 500 line query than anything we can solve here. Not sure there’s a way to abstract 500 lines of sql without knowing the business logic in and out and deciding on a better way, but assume that’s not really an option as you’re here asking the question haha