Reputation: 420
I am using Intellij to write a Kotlin repository using JPA. I converted an existing Java class which had a particularly long @Query string.
@Query("SELECT a.column1, a.column2, b.column3, b.column4, b.column5, b.column6) FROM TableA as a JOIN TableB as b ON a.id = b.foreignKeyId WHERE a.column1 = :column1 AND b.column2 = :column2 AND b.column3 IN :column3Values")
public List someFancyMethodName(...);
After converting to Kotlin I turned the annotation parameter into a multiline string and started inserting newlines. Intellij, (helpfully?), inserted pipes for handling the margin.
It ended up looking like this.
@Query("""SELECT a.column1, a.column2, b.column3, b.column4, b.column5, b.column6)
| FROM TableA as a
| JOIN TableB as b ON a.id = b.foreignKeyId
| WHERE a.column1 = :column1
| AND b.column2 = :column2
| AND b.column3 IN :column3Values""")
fun someFancyMethodName(...): List<SomeFancyReturnValue>
My first thought is that this is not going to work with the embedded pipes and that Intellij shouldn't be inserting them in an annotation parameter. Or is it smart enough to remove the pipes a on compile when the multiline string is an annotation parameter?
Upvotes: 4
Views: 1406