春季关系问题

时间:2020-11-12 12:14:29

标签: java spring database kotlin relationship

在这种情况下我该怎么办?我需要将其从集合和对象中删除还是仅从对象中删除?

val x = xRepo.findById(id)
val y = x.y

// Option one
x.y = y
// Option two
y.xList = y.xList.add(x)
// Option three
x.y = y
y.xList = y.xList.add(x)

第二个问题:

在这种情况下会发生什么?

val x = xRepo.findById(id)
val y = x.y

xRepo.delete(x)


// What happens to the x in the y collection? Do I need to remove it before it deletes it or will spring do it??

0 个答案:

没有答案