-
Notifications
You must be signed in to change notification settings - Fork 361
DATAJDBC-234 - Support properties file based query declaration #134
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
@mcisnerosb57 Please sign the Contributor License Agreement! Click here to manually synchronize the status of this Pull Request. See the FAQ for frequently asked questions. |
@mcisnerosb57 Thank you for signing the Contributor License Agreement! |
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 should have at least one integration test demonstrating this feature.
I also pointed out some issues in additional comments.
...ata-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethod.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java
Outdated
Show resolved
Hide resolved
|
Do you need anything else?. thank you very much. |
Nothing but some more time. I'll look at this PR probably somewhere next week. |
|
sorry im close the issue by error. |
thanks very much for your comment. |
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.
Integration tests in the context of this project are those that are named *IntegrationTests
and actually interact with a database.
You could add two test methods to JdbcRepositoryIntegrationTests
one for a named query based on the method name and one based on a `@Query(name =...) annotation.
* @return May be {@code null}. | ||
*/ | ||
@Nullable | ||
public String getValueNamedQuery() { |
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.
getNamedQuery
is probably a better name.
*/ | ||
@Nullable | ||
public String getValueNamedQuery() { | ||
String annotatedName = getMergedAnnotationAttribute("name"); |
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.
Sorry, it seems I wasn't clear here.
If no name is specified, the method name should be used a the name for the named query.
Hi, i ve problems with de spring-data-jdbc . i cant realize mvn install , and when i cant import project because the libraly kotlin-maven-plugin: No marketplace entries found to handle Execution compile, in /spring-data-jdbc/pom.xml in Eclipse. Please see Help for more information. [ERROR] Failures: [ERROR] JdbcRepositoryQueryUnitTests.publishesSingleEventWhenQueryReturnsSingleAggregate:169 [INFO] |
Great to see you are still working on this. You are hinting at three different problems: I'm not sure I'll be able to help with b) since I don't use that IDE. |
MVN install error: [ERROR] JdbcRepositoryQueryUnitTests.publishesSingleEventWhenQueryReturnsSingleAggregate:169 [INFO] Thanks very much |
Is this with the latest version of the master branch? Because it looks like an issue that we had some time ago when we updated Mockito. Please make sure to pull the latest changes and run with |
the following things is happening in the integration test:
// @query(name= "dummyentity.findbyId")
|
Have you been able to fix your development environment problems? The PR builds ok for me. |
spring-data-jdbc/pom.xml
Outdated
@@ -122,14 +122,31 @@ | |||
<version>${mybatis.version}</version> | |||
<optional>true</optional> | |||
</dependency> | |||
|
|||
<dependency> |
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.
Please do not add additional dependencies.
spring-data-jdbc/pom.xml
Outdated
<dependency> | ||
<groupId>org.hsqldb</groupId> | ||
<artifactId>hsqldb</artifactId> | ||
<version>${hsqldb.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.hibernate</groupId> |
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.
Especially not Hibernate.
@@ -0,0 +1,117 @@ | |||
package org.springframework.data.jdbc.repository; | |||
|
|||
import static org.junit.Assert.assertEquals; |
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 prefer AssertJ assertions.
import java.util.stream.Stream; | ||
|
||
@RunWith(SpringRunner.class) | ||
@ContextConfiguration("classpath:application-context.xml") |
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.
Please take a look how other intergration-tests are setup and construct any new tests the same way.
But really you can just add tests to existing integration-tests. JdbcRepositoryIntegrationTests
is a good candidate.
@@ -50,6 +71,9 @@ | |||
@Transactional | |||
public class JdbcRepositoryIntegrationTests { | |||
|
|||
Logger logger = LoggerFactory.getLogger(JdbcRepositoryIntegrationTests.class); |
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.
This isn't needed.
@@ -255,11 +255,11 @@ public void executeCustomModifyingQueryWithReturnTypeVoid() { | |||
assertThat(repository.findByNameAsEntity("Spring Data JDBC")).isNotNull(); | |||
} | |||
|
|||
@Test // DATAJDBC-175 | |||
/*@Test // DATAJDBC-175 |
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.
Please do not remove tests.
import lombok.Data; | ||
import org.springframework.data.annotation.Id; | ||
|
||
import javax.persistence.GeneratedValue; |
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.
Don't use javax.persistence
import javax.persistence.GeneratedValue; | ||
|
||
@Data | ||
public class DummyEntity { |
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.
Please create test entities as static inner classes.
|
||
import java.util.stream.Stream; | ||
|
||
@Repository |
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.
You don't need an @Repository
annotation on an interface extending @CrudRepository
import java.util.stream.Stream; | ||
|
||
@Repository | ||
public interface DummyEntityRepository extends CrudRepository<DummyEntity, Long> { |
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.
Just as entities for testing, please use static inner interfaces for repositories used in tests.
I need to be able to pull the code to update it. Thank you! |
You don't need more than reading access to the repository.
|
364ce8c
to
7a738ee
Compare
the name parameter has been created for Query.class.The NamedQuery interface is used to extract from the properties file called jdbc-named-queries.properties.Test jUnit created. modified: spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/Query.java, modified: spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategy.java, modified: spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethod.java , modified: spring-data-jdbc/src/test/java/org/springframework/data/jdbc/repository/support/JdbcQueryMethodUnitTests.java