@Id
@GeneratedValue(strategy = GenerationType.AUTO)
val id: UUID? = null,
@Column(insertable = false, updatable = false)
val createdAt: LocalDateTime? = null,
@Column(insertable = false, updatable = false)
val updatedAt: LocalDateTime? = null,
var name: String,
var code: String,
@OneToMany(fetch = FetchType.LAZY, mappedBy = "department")
val users: List<UserEntity>? = listOf()
)
и
@Entity
@Table(name = "users")
class UserEntity(
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
val id: UUID? = null,
@Column(insertable = false, updatable = false)
val createdAt: LocalDateTime? = null,
@Column(insertable = false, updatable = false)
val updatedAt: LocalDateTime? = null,
var firstName: String,
var lastName: String,
var middleName: String? = null,
var email: String,
var blocked: Boolean? = false,
var hidden: Boolean? = false,
@ManyToOne(fetch = FetchType.LAZY)
var department: DepartmentEntity? = null
)
можно ли как-то без использования @JsonManagedReference и @JsonBackReference избавится от Could not write JSON: Infinite recursion ?
все оказалось довольно просто ) @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator::class, property = "id")
Обсуждают сегодня