Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[BUG] - Select an object with backward association filtering #1247

Open
Labels
bugSomething isn't working
@kors2m

Description

@kors2m

Jimmer Version

0.9.113

JDK Version

JDK21

Database

Postgres

OS

Linux

Expected behavior

Get an object with applied filtering by backward association

Actual behavior

Get an object without filtering by backward association

Description

The select for inner objects is generated without a predicate in where

Reproduction steps

        var document = DocumentDraft.$.produce(documentDraft -> {            documentDraft.setType("type");            documentDraft.addIntoFiles(fileDraft -> {                fileDraft.setLink("link1");            });            documentDraft.addIntoFiles(fileDraft -> {                fileDraft.setLink("link2");            });        });        var newDocument = sqlClient.saveCommand(document)            .setMode(SaveMode.INSERT_ONLY)            .setAssociatedModeAll(AssociatedSaveMode.APPEND)            .execute()            .getModifiedEntity();        // Need to get a document with a specific fileId        var documentTable = DocumentTable.$;        var documentWithSpecificFile = sqlClient            .createQuery(documentTable)            .where(documentTable                .files(fileTableEx -> fileTableEx.id().eq(newDocument.files().getFirst().id())))            .select(                documentTable.fetch(                    DocumentFetcher.$.allScalarFields().files(FileFetcher.$.allScalarFields())                )            )            .fetchOneOrNull();        System.out.println(documentWithSpecificFile.files().size()); // selected all files, but expected filtered files

Generated SQL

select    tb_1_.ID,    tb_1_.TYPEfrom DOCUMENT tb_1_where    exists(        select            1        from FILE tb_2_        where                tb_2_.DOCUMENT_ID = tb_1_.ID            and                tb_2_.ID = 'd52cf581-46b3-49a1-82a0-c44669918485'    )limit 2
select    tb_1_.ID,    tb_1_.LINKfrom FILE tb_1_where    tb_1_.DOCUMENT_ID = '3ba9606a-629c-4569-af07-3ca70525975a'

Relation Model

@Entitypublic interface Document {    @Id    @GeneratedValue(generatorType = UUIDIdGenerator.class)    @NotNull    UUID id();    @Nullable    String type();    @OneToMany(mappedBy = "document")    @NotNull    List<File> files();}
@Entitypublic interface File {    @Id    @GeneratedValue(generatorType = UUIDIdGenerator.class)    @NotNull    UUID id();    @ManyToOne    @NotNull    Document document();    @NotNull    String link();}
create table document(    id   uuid not null primary key,    type varchar(100));create table file(    id          uuid not null primary key,    document_id uuid not null,    link        text not null);alter table file    add foreign key (document_id) references document (id);

Screenshots

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp