babyfish-ct / jimmer

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

Incorrect `@Formula` attribute type in generated draft class #620

Closed aboutZZ closed 1 month ago

aboutZZ commented 1 month ago

Dependency

Issue description

The entity class has a @Formula attribute permissionsCollection which returns Set<String>, But in the generated draft class, permissionsCollection has a wrong type List<String>, causes compile error: Type of 'permissionsCollection' is not a subtype of overridden property '@Formula(...) val permissionsCollection: Set<String>'.

// Entity
@Table(name = "sys_role")
@Entity
interface SystemRole : AbstractEntity {

    val id: Long

    @ManyToMany(orderedProps = [OrderedProp("sort")])
    @JoinTable(name = "sys_role_permission", joinColumnName = "role_id", inverseJoinColumnName = "permission_id")
    val permissions: List<SystemPermission>

    @Formula(dependencies = ["permissions"])
    val permissionsCollection: Set<String>
        get() = permissions.map { it.permission }.filterNotNull()
            .filter { it.isNotEmpty() }.toSet()
}

// Draft class
public interface SystemRoleDraft : SystemRole, AbstractEntityDraft {

    override val permissionsCollection: List<String>
}
babyfish-ct commented 1 month ago

Try 0.8.151