spring-projects / spring-data-relational

Spring Data Relational. Home of Spring Data JDBC and Spring Data R2DBC.
https://spring.io/projects/spring-data-jdbc
Apache License 2.0
772 stars 346 forks source link

Filtering by nested property #1227

Open jopasb opened 2 years ago

jopasb commented 2 years ago

Hi, I'm using spring-data-jdbc 2.3.1 and by reading https://docs.spring.io/spring-data/jdbc/docs/current/reference/html/#repositories.query-methods.query-property-expressions , find by nested properties should work, but when I write method that tries to filter by nested property, I get an error: Cannot query by nested property Reference is 1on1. Should this be supported by spring-data-jdbc?

schauder commented 2 years ago

Query derivation is currently only supported for direct properties.

There should be already a ticket for this I think, but I can't find it.

Sorry for the somewhat misleading documentation. The part you are referring to is for all Spring Data modules and not everything in that section is supported by all modules.

jopasb commented 2 years ago

Hi Jens, thanks for a quick response. Do you know maybe in which release should be this change?

schauder commented 2 years ago

We currently do not have a timeline for this.

ElTav commented 1 year ago

@schauder Any update on whether you've gotten around to adding a timeline for this?

genuss commented 10 months ago

@ElTav I use the following hack in my case:

select direct.*,
       nested.id                             nested_id,
       nested.column1                        nested_column1,
       nested.column2                        nested_column2
from direct join nested on direct.id = nested.id
where nested.column1 = :nestedColumn1Value
order by direct.id

It works at least in my case with 1-1 relantionship. It's a bit clunky because you have to include all nested table column names.