You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JPQL syntax highlighting support with constant string concatenation #1460
Similar to issue #1262, but with constants. It's best if I explain this with an example. Syntax highlighting for inline string inside query annotation does not work in this case, because the inline string is concatenated with a constant:
@Data@AllArgsConstructorpublicclassUserDao {
privateUUIDuserId;
privateStringname;
publicstaticfinalStringSELECT =
""" SELECT new com.package.UserDao( u.id, u.name ) """;
}
publicinterfaceUserRepoextendsJpaRepository<User, UUID> {
@Query(
UserDao.SELECT +
""" FROM User u WHERE u.id IN :ids """
)
List<UserDao> findAllByIdIn(Collection<UUID> ids);
}
Current Behavior
Syntax highlighting works properly when we only concatenate inline strings like following:
publicinterfaceUserRepoextendsJpaRepository<User, UUID> {
@Query(
""" SELECT new com.package.UserDao( u.id, u.name ) """ +
""" FROM User u WHERE u.id IN :ids """
)
List<UserDao> findAllByIdIn(Collection<UUID> ids);
}
Context
The use case is to reduce duplicate code for queries that use the same data access object, and centralize the implementation so when any changes made to access object, changing only one string will be sufficient for all queries.
I'm using VS Code as code editor, here's some screenshots to show the difference:
Activity
BoykoAlex commentedon Feb 25, 2025
Fixed via 5009808