-
Notifications
You must be signed in to change notification settings - Fork 361
DATAJDBC-234 - Support properties file based query declaration #180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This supersedes #134. |
Good Morning, i have this error but not everytime. [ERROR] Failures:
|
Interesting, kind of strange that I haven't seen that one. Please create a new issue for that one and please include the JDK version you are using. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two major things we need before I can proceed with merging this:
-
We need a way to configure a property file to use including a decent default value. Compare https://github.com/spring-projects/spring-data-jpa/blob/master/src/main/java/org/springframework/data/jpa/repository/config/EnableJpaRepositories.java#L97
-
The method name should be used as the default name for the lookup.
I also left some more detailed comments.
spring-data-jdbc/src/test/java/org/springframework/data/jdbc/testing/TestConfiguration.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java
Outdated
Show resolved
Hide resolved
...c/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIntegrationTests.java
Show resolved
Hide resolved
...c/src/test/java/org/springframework/data/jdbc/repository/JdbcRepositoryIntegrationTests.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java
Show resolved
Hide resolved
...src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java
Show resolved
Hide resolved
...ata-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethod.java
Show resolved
Hide resolved
String annotatedName = getMergedAnnotationAttribute("name"); | ||
return (StringUtils.hasText(annotatedName) && this.namedQueries.hasQuery(annotatedName)) | ||
? this.namedQueries.getQuery(annotatedName) | ||
: super.getName(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't return the name of the method as a query, we have to use it as the query name to look up a query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is looking up the query?, in the properties file?.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly.
Don't worry about the Travis build a fix for that is in the working. The important part is that a local |
not understand what you mean . the default file is jdbc-named-query.properties. And it change if indicat the property file . |
Do you need any thing more? . thanks |
Queries are expected in a properties file on the classpath `META-INF/jdbc-named-queries.properties`. The name of the query is by default `<simple class name of the domain type>.<methodName>`. Alternatively it can be set using the `@Query` annotations `name` attribute. Original pull request: #180.
The default name now does include the name of the domain class. The default name now is no longer used when no query with the name specified in the `@Query` annotation is found. Simplified the unit tests by extracting common functionality and improving naming. Simplified test configuration. Original pull request: #180.
Thanks, I moved some things around and merged it into master. |
JDBC-234 with a integration test.