1

So I've read the Spring documentation that states that when you have property names with an underscore (first_name) you should escape and underscore in a query method by using another underscore (findByFirst__name(...)).

Spring Data Documentation

However, in practice this does not work and we get a runtime error stating that the property first cannot be found. This has been documented by other devs here:

Link 1 Link 2

But none of the provided answers addresses the fact that this is not working properly in practice. Most answers state to remove the underscore from the property name.... which is not always an easy or possible task. Can anyone confirm that they actually have gotten this to work? My guess is that there is a bug in Spring-data but for some reason no one has acknowledged this or filed a bug yet.

Is there a workaround to this problem that anyone has had success with besides renaming the database field?

Community
  • 1
  • 1
blast7
  • 45
  • 10

1 Answers1

1

I debugged the spring-data-commons 1.9.2.RELEASE version and created the following pull request since the code seems not to handle this case. For further information please review the following link:

https://github.com/spring-projects/spring-data-commons/pull/126

Read here: https://jira.spring.io/browse/DATACMNS-569

swinkler
  • 1,703
  • 10
  • 20
  • Excellent! Thanks for confirming this and logging the issue, I thought I was losing it (not the first time). – blast7 Jun 02 '15 at 17:43
  • Thanks for that link. I decided to rename all the database fields so that they are not using underscores. However now I have run into an issue where once a Query completes the class loader spring is using can't find my model classes in the classpath (this is in a play framework application). I'm doing some research now and will form a new question with all the particulars once I have all the info together – blast7 Jun 03 '15 at 18:12