nb-springboot icon indicating copy to clipboard operation
nb-springboot copied to clipboard

Please add completion/suggestion for creating repo methods

Open Chris2011 opened this issue 7 years ago • 6 comments
trafficstars

In this improvements list: https://blog.jetbrains.com/idea/2017/03/spring-data-improvements-in-intellij-idea-2017-1/ if you scroll down a bit to the Smarter Code Completion section, you can see, that they suggest keywords to create repo methods for the mapped SQL, what Spring does in the background. This is very handy, if you didn't create your repo method before, but if you want to create it ad hoc.

Cheers

Chris

Chris2011 avatar Mar 23 '18 12:03 Chris2011

Here i the gif of the section: https://d3nmt5vlzunoa1.cloudfront.net/idea/files/2017/03/05FindByZipNestedParam.gif

Chris2011 avatar Mar 23 '18 12:03 Chris2011

@Chris2011 this is a very complex feature so I will likely not have time to implement it. Hope someone will step up and help.

AlexFalappa avatar Mar 24 '18 15:03 AlexFalappa

Yeah, I thought so too. Thx for the info. Hope too, that someone can catch up.

Chris2011 avatar Mar 24 '18 15:03 Chris2011

I'm just thinking we can get ideas from JPA's @NamedQuery completion to achieve this feat.

essien avatar Feb 23 '21 10:02 essien

It seems that it just check the properties of the object and can chain them together with And or other operators: https://docs.spring.io/spring-data/commons/docs/current/reference/html/#repositories.query-methods.query-property-expressions

Chris2011 avatar Sep 29 '23 13:09 Chris2011

I already had a look into the functionality how this works. A colleague of mine helped me understanding it. It seems that it is working as mentioned before somehow. You have a model and inside the repository class it goes through your model based on the generic type that you aligned as T and the IDE goes through your Pojo and adds some basic keywords, your propertyname and operators to it. Here is a little example to test it out.

demochris.zip

Maybe that makes it easier to implement such functionality into the code completion.

Chris2011 avatar Nov 01 '23 17:11 Chris2011