babyfish-ct / jimmer

A revolutionary ORM framework for both java and kotlin.
Apache License 2.0
877 stars 88 forks source link

[bug] @OneToOne update error #682

Closed belovaf closed 1 month ago

belovaf commented 1 month ago

Model:

@Entity
@KeyUniqueConstraint
interface Child : SerialId {

    @Key
    @OneToOne
    val parent: Parent

    val name: String
}

@Entity
interface Parent : SerialId {
    @OneToOne(mappedBy = "parent")
    val child: Child?

    val name: String
}

Code:

sql.save(Parent {
            id = 1
            child {
                name = "new name"
            }
        }) {
            setMode(SaveMode.UPDATE_ONLY)
            setAssociatedModeAll(AssociatedSaveMode.UPDATE)
        }

Generated sql:

update CHILD set ID = ID, NAME = ? where PARENT_ID = ? returning ID

Expected sql:

update CHILD set NAME = ? where PARENT_ID = ? returning ID
babyfish-ct commented 1 month ago

Done, please pull the branch dev