我在 wiki 中完成了 ExposedBD (kotlin) 中的多对多引用,如下所示: https ://github.com/JetBrains/Exposed/wiki/DAO#many-to-many-reference
但是,当我尝试在我的 API (Javalin) 中返回对象列表时,会出现无限递归 (Jackson) 的问题。所以,我想知道如何放置注释@jsonIgnore
,或者在这种情况下是否有其他替代解决方案。这是映射:
// many-to-many Actor--StarWarsFilms
// Actor Entity
object Actors: IntIdTable() {
val firstname = varchar("firstname", 50)
val lastname = varchar("lastname", 50)
}
class Actor(id: EntityID<Int>): IntEntity(id) {
companion object : IntEntityClass<Actor>(Actors)
var firstname by Actors.firstname
var lastname by Actors.lastname
}
// StarWarFilm Entity
object StarWarsFilms : IntIdTable() {
val sequelId = integer("sequel_id").uniqueIndex()
val name = varchar("name", 50)
val director = varchar("director", 50)
}
class StarWarsFilm(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<StarWarsFilm>(StarWarsFilms)
var sequelId by StarWarsFilms.sequelId
var name by StarWarsFilms.name
var director by StarWarsFilms.director
var actors by Actor via StarWarsFilmActors
}
// Intermediate table
object StarWarsFilmActors : Table() {
val starWarsFilm = reference("starWarsFilm", StarWarsFilms).primaryKey(0)
val actor = reference("actor", Actors).primaryKey(1)
}