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

Questions on projection/DTO nesting #633

Closed
cambierr opened this issue Aug 1, 2021 · 2 comments
Closed

Questions on projection/DTO nesting #633

cambierr opened this issue Aug 1, 2021 · 2 comments
Labels
status: duplicate A duplicate of another issue

Comments

@cambierr
Copy link

cambierr commented Aug 1, 2021

Hi,

Based on https://docs.spring.io/spring-data/r2dbc/docs/current/reference/html/#projections I understand that nesting is supposed to work, which I'm about to investigate but I'm wondering how this is actually working and what's allowed.

First, given a tables A(col_a1, col_a2) and B(col_b1, col_b2, col_a1), the last column of B being a foreign key to A.col_a1. The documentation seems to say that something like

class A{
    String colA1;
    String colA2;
    B b;

    static class B{
        String colB1;
        String colB2;
    }
};

interface ARepository extends Repository<A, String> {
    Flux<A> findBycolA1(String colA1);
}

How is this supposed to be mapped to a + a.b ?

I guess we should build something like

interface ARepository extends Repository<A, String> {
    @Query("SELECT * FROM A WHERE col_a1 = :colA1 join B on a.colA1 = b.colA1")
    Flux<A> findBycolA1(String colA1);
}

and I can understand that the mapping would work using this model. Would it be right ?

A final question would then be; if 1-to-1 mapping works, should 1-to-n mapping work too ? If so, under which conditions ?

Thank you already, guys.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 1, 2021
@mp911de
Copy link
Member

mp911de commented Sep 28, 2021

Relational nesting isn't supported yet by Spring Data R2DBC.

@mp911de mp911de added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 28, 2021
@mp911de
Copy link
Member

mp911de commented Sep 28, 2021

Duplicates #356 and #288

@mp911de mp911de closed this as completed Sep 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants