Skip to content
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

Derived Queries [DATAJDBC-318] #541

Closed
spring-projects-issues opened this issue Jan 15, 2019 · 18 comments
Closed

Derived Queries [DATAJDBC-318] #541

spring-projects-issues opened this issue Jan 15, 2019 · 18 comments
Assignees
Labels
in: repository type: enhancement

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jan 15, 2019

Jens Schauder opened DATAJDBC-318 and commented

We should add support for derived queries, i.e query generation from property names.

The infrastructure for this is already provided by Spring Data Commons, so it should be not to difficult to implement.

Only supporting simple properties, i.e. properties directly owned by the aggregate root is fine as a first step.

For hints how to implement this consult the Spring Data Mongo source code and search for usage of PartTree which is the structure that results from parsing a method name


Referenced from: pull request #209

5 votes, 10 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jan 18, 2019

Thomas Lang commented

Just for your information, i am currently working on that issue

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented May 20, 2019

James Clark commented

Thomas Lang, are you still working on this? 

 

If not, Jens Schauder, I don't suppose you would be available to give me some pointers so I can tackle it?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented May 28, 2019

James Clark commented

Hi Jens Schauder, I have taken a crack at this...well a start. I was hoping you could give me some early feedback as to if it's the sort of thing you're after or if it's not up to scratch at all. I created a PR against my private fork here jamesclark92#1

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 4, 2019

Jens Schauder commented

James Clark I'll take a look.

I also happen to know that Thomas Lang is actually still working on this.
Sorry for not replying to you earlier.
I assumed Thomas would react and than lost track of that

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 4, 2019

Jens Schauder commented

James Clark this looks really good.

And a lot of stuff.
I underestimated the task 😰

The only mayor thing I noticed is that I'm considering to go through the JdbcAggregateTemplate and do the SQL generation in there instead of doing the SQL generation directly.
But even that isn't a big issue

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 6, 2019

Thomas Lang commented

Dear James Clark,
Dear Jens Schauder

... i´m sorry that i did not keep the information flow up to date with this issue.
The issue is (for my part) nearly done. I only need to tailor some tests then i can submit a pull request.

Sorry again for my delay and not keeping this up to date here.

Jens Schauder What is your opinion on this?
Should we merge mine and James´ version together?

Kind regards
Thomas

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 6, 2019

Jens Schauder commented

From my selfish perspective throwing the stuff from both of you together and creating a single PR would be best.
Maybe if you Thomas Lang see anything that your code handles that James Clark doesn't you could do a PR on his repository and then create a PR from the result?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 6, 2019

Thomas Lang commented

... i have shortly reviewed James Clark code. There are some new/other snippets in it than in mine.
The question now - in my opinion - is which code base we may use as a basis of a merge?
As for my understanding things done in James Clark code works the same as in mine yet coded slightly different.

James Clark Should we take your version or my version and work the others code into it?
Jens Schauder Do you have a tendency which way we should go?
Mix mine into James or mix James into mine?

Currently i don´t know where to start from. Another important aspect is time management.
I see that James Clark has done a lot of work in a very short time.
So maybe it would be faster if James Clark mixes my work into his?

I appreciate your suggestions :)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 7, 2019

Thomas Lang commented

Hello Jens Schauder
Hello James Clark
i have just finished my work on this issue - please see this link:
https://github.com/THD-Thomas-Lang/spring-data-jdbc/tree/datajdbc-318

I have reviewed and checked James` code once again an i have difficulties to decide which things work out better:

Jens Schauder Would you mind taking a look into my version and then decide which way to go?
Maybe we can do a google hangouts session to get things together?

Any suggestions/tipps are very welcome to me as i´m actually a bit confused what to do :)
Kind regards
Thomas

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 7, 2019

James Clark commented

Hey Thomas, perhaps you can tell me what your features/functionality yours has that mine doesn't? Then I can incorporate them into mine... But I guess the best way would be for one of us to raise a PR to the others

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 9, 2019

Jordan LEFEBURE commented

Hello James Clark Thomas Lang,

I'm currently working on a fork of Spring Data JDBC for a specific database engine which work with SQL queries. This feature is of course a great improvement for the project.

I will test both PR and make a review if it can help

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jun 11, 2019

Thomas Lang commented

Dear James Clark,
i´ve just created a pull request - see: jamesclark92#2

From my point of view, my code does the more or less the same as yours with some different approaches.
I think that my tests are covering more. Furthermore my feature set is yet clearly defined.

  • just two simple properties (firstname, lastname)
  • no father-child relations
  • only and connector
  • only one connector

My main classes are:
https://github.com/THD-Thomas-Lang/spring-data-jdbc/blob/datajdbc-318/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/PartTreeExecutor.java
https://github.com/THD-Thomas-Lang/spring-data-jdbc/blob/datajdbc-318/spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/PartTreeJdbcRepositoryQuery.java
There are tests for each of those.

I hope this helps you? Please respond if you need further information.
Thank you!
Thomas

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Dec 2, 2019

Jens Schauder commented

Hi James Clark,

could you provide a PR against https://github.com/spring-projects/spring-data-jdbc in order to make it clear that you want your changes to end up in the main repository?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 20, 2020

James Clark commented

I am more than happy for you to use my changes! 

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 20, 2020

Mark Paluch commented

We received recently a contribution to Spring Data R2DBC which brought query derivation. We're going to add query derivation based on the existing infrastructure as there's no pull request available for Spring Data JDBC

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 23, 2020

lseeker commented

Test with issue/DATAJDBC-318 branch, current code has problem with relations.

If entity has relation(@MappedCollection) like Set<OtherEntity> others, derived query contains “others” as Column on select query, results SQLSyntaxErrorException: Unknown column ‘others’ in ‘field list’.

It will better PartTreeJdbcQueryUnitTests contains relations like SqlGeneratorUnitTests.

Thanks.

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 23, 2020

Jens Schauder commented

Thanks for the pointer lseeker. We'll look into that

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Apr 28, 2020

Jens Schauder commented

We now support query derivation as long as the constraints only use direct properties of the aggregate root or of embedded entities.

Referenced entities (1:1 and 1:N) get loaded as usual, but must not be used for constraints

@spring-projects-issues spring-projects-issues added in: repository type: enhancement labels Dec 31, 2020
mp911de added a commit that referenced this issue Feb 21, 2022
mp911de added a commit that referenced this issue Feb 21, 2022
mp911de added a commit that referenced this issue Feb 21, 2022
mp911de added a commit that referenced this issue Feb 21, 2022
mp911de added a commit that referenced this issue Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants