ebean: Q: Why can't kapt kotlin generate var Set to query bean
@Entity
@Table(name = "sys_user")
open class SysUser {
var name: String? = null
@ManyToMany
var roles: Set<SysRole>? = null
@OneToOne
@JoinColumn(name = "job_id")
var job: SysJob? = null
}
@Generated("io.ebean.querybean.kotlin-generator")
@TypeQueryBean
class QSysUser : TQRootBean<SysUser, QSysUser> {
companion object {
/**
* shared 'Alias' instance used to provide
* properties to select and fetch clauses
*/
val _alias = QSysUser(true)
}
lateinit var name: PString<QSysUser>
lateinit var job: QAssocSysJob<QSysUser>
/**
* Construct with a given EbeanServer.
*/
constructor(server: EbeanServer) : super(SysUser::class.java, server)
/**
* Construct using the default EbeanServer.
*/
constructor() : super(SysUser::class.java)
/**
* Construct for Alias.
*/
private constructor(dummy: Boolean) : super(dummy)
}
lost roles in query bean
If I replace
var roles: Set < SysRole >? = null
for
val roles: Set < SysRole >? = null
It generates
lateinit var roles: QAssocSysRole<QSysUser>
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 20 (13 by maintainers)
Yes I see that just arrive, great thanks!!
If more people / organisations did that we could dedicate more time, get better documentation etc. Thanks for the donation!!
Cheers, Rob.
I donated $10 as a thank you. I really like your project and admire your work.
Yes quite right. Note that UUID can be encoded to binary(16) for databases that don’t have native uuid support. So binary(16) could be considered better that varchar in the sense of smaller storage, smaller indexes etc.
We can review the
db-create-all.sqlfor the generated foreign key names like:Generally if this is a new DB schema I’d pretty much not expect any
@JoinColumnor@JoinTableannotations.as these all have good defaults via the naming convention.For example, the
@JoinColumncan be removed - that matches the naming convention so isn’t needed.Side notes, suggestions for making more things Kotlin non-nullable types:
Instead of this …
Make it a non nullable type …
Instead of …
Have username as a constructor parameter of non-nullable String …
Note that for we also need this fix: https://github.com/ebean-orm/ebean/issues/1804