为了账号安全,请及时绑定邮箱和手机立即绑定

关于inverse 和cascade属性的问题

在多对多关系中,双方都持有对方的集合,比方Student 和Teacher 这两个类。在配置映射关系的时候,如果我选择Teacher方为维护双方的关联关系的一方,那么inverse和cascade这两个属性应该在student.hbm.xml配置还是teacher.hbm.xml文件中配置呢?inverse = true表示由对方维护,而inverse是Set的子元素,是不是意味着我应该在teacher.hbm.xml的Set中配置呢??我对这点一直比较晕,希望有人指点下

正在回答

2 回答

https://m.vk.com/@712772904-93963
https://m.vk.com/@712772904-93981
https://m.vk.com/@712772904-93999
https://m.vk.com/@712772904-94018
https://m.vk.com/@712772904-94036
https://m.vk.com/@712772904-94087
https://m.vk.com/@712772904-94088
https://m.vk.com/@712772904-94089
https://m.vk.com/@712772904-94090
https://m.vk.com/@712772904-94091
https://m.vk.com/@712772904-94092
https://m.vk.com/@712772904-94093
https://m.vk.com/@712772904-94094
https://m.vk.com/@712772904-94095
https://m.vk.com/@712772904-94096
https://m.vk.com/@712772904-94097
https://m.vk.com/@712772904-94098
https://m.vk.com/@712772904-94099
https://m.vk.com/@712772904-94100
https://m.vk.com/@712772904-94101
https://m.vk.com/@712772904-94102
https://m.vk.com/@712772904-94103
https://m.vk.com/@712772904-94104
https://m.vk.com/@712772904-94105
https://m.vk.com/@712772904-94106
https://m.vk.com/@712772904-94107
https://m.vk.com/@712772904-94108
https://m.vk.com/@712772904-94109
https://m.vk.com/@712772904-94110
https://m.vk.com/@712772904-94111
https://m.vk.com/@712772904-94112
https://m.vk.com/@712772904-94113
https://m.vk.com/@712772904-94114
https://m.vk.com/@712772904-94115
https://m.vk.com/@712772904-94116
https://m.vk.com/@712772904-94117
https://m.vk.com/@712772904-94118
https://m.vk.com/@712772904-94119
https://m.vk.com/@712772904-94120
https://m.vk.com/@712772904-94121
https://m.vk.com/@712772904-94122
https://m.vk.com/@712772904-94123
https://m.vk.com/@712772904-94124
https://m.vk.com/@712772904-94125
https://m.vk.com/@712772904-94126
https://m.vk.com/@712772904-94127
https://m.vk.com/@712772904-94128
https://m.vk.com/@712772904-94129
https://m.vk.com/@712772904-94130
https://m.vk.com/@712772904-94131
https://m.vk.com/@712772904-94132
https://m.vk.com/@712772904-94133
https://m.vk.com/@712772904-94134
https://m.vk.com/@712772904-94135
https://m.vk.com/@712772904-94136
https://m.vk.com/@712772904-94137
https://m.vk.com/@712772904-94138
https://m.vk.com/@712772904-94139
https://m.vk.com/@712772904-94140
https://m.vk.com/@712772904-94141
https://m.vk.com/@712772904-94142
https://m.vk.com/@712772904-94143
https://m.vk.com/@712772904-94144
https://m.vk.com/@712772904-94145
https://m.vk.com/@712772904-94146
https://m.vk.com/@712772904-94147
https://m.vk.com/@712772904-94148
https://m.vk.com/@712772904-94149
https://m.vk.com/@712772904-94150
https://m.vk.com/@712772904-94151
https://m.vk.com/@712772904-94152
https://m.vk.com/@712772904-94153
https://m.vk.com/@712772904-94154
https://m.vk.com/@712772904-94155
https://m.vk.com/@712772904-94156
https://m.vk.com/@712772904-94157
https://m.vk.com/@712772904-94158
https://m.vk.com/@712772904-94159
https://m.vk.com/@712772904-94160
https://m.vk.com/@712772904-94161
https://m.vk.com/@712772904-94162
https://m.vk.com/@712772904-94163
https://m.vk.com/@712772904-94164
https://m.vk.com/@712772904-94165
https://m.vk.com/@712772904-94166
https://m.vk.com/@712772904-94167
https://m.vk.com/@712772904-94168
https://m.vk.com/@712772904-94169
https://m.vk.com/@712772904-94170
https://m.vk.com/@712772904-94171
https://m.vk.com/@712772904-94172
https://m.vk.com/@712772904-94173
https://m.vk.com/@712772904-94174
https://m.vk.com/@712772904-94182
https://m.vk.com/@712772904-94187
https://m.vk.com/@712772904-94188
https://m.vk.com/@712772904-94189
https://m.vk.com/@712772904-94193
https://m.vk.com/@712772904-94196
https://m.vk.com/@712772904-94197
https://m.vk.com/@712772904-94198
https://m.vk.com/@712772904-94203
https://m.vk.com/@712772904-94207
https://m.vk.com/@712772904-94208
https://m.vk.com/@712772904-94209
https://m.vk.com/@712772904-94310
https://m.vk.com/@712772904-94329
https://m.vk.com/@712772904-94348
https://m.vk.com/@712772904-94359
https://m.vk.com/@712772904-94366
https://m.vk.com/@712772904-94367
https://m.vk.com/@712772904-94368
https://m.vk.com/@712772904-94369
https://m.vk.com/@712772904-94370
https://m.vk.com/@712772904-94371
https://m.vk.com/@712772904-94372
https://m.vk.com/@712772904-94373
https://m.vk.com/@712772904-94374
https://m.vk.com/@712772904-94375
https://m.vk.com/@712772904-94376
https://m.vk.com/@712772904-94377
https://m.vk.com/@712772904-94378
https://m.vk.com/@712772904-94379
https://m.vk.com/@712772904-94380
https://m.vk.com/@712772904-94381
https://m.vk.com/@712772904-94382
https://m.vk.com/@712772904-94383
https://m.vk.com/@712772904-94384
https://m.vk.com/@712772904-94385
https://m.vk.com/@712772904-94386
https://m.vk.com/@712772904-94387
https://m.vk.com/@712772904-94388
https://m.vk.com/@712772904-94389
https://m.vk.com/@712772904-94390
https://m.vk.com/@712772904-94391
https://m.vk.com/@712772904-94392
https://m.vk.com/@712772904-94393
https://m.vk.com/@712772904-94394
https://m.vk.com/@712772904-94395
https://m.vk.com/@712772904-94396
https://m.vk.com/@712772904-94397
https://m.vk.com/@712772904-94398
https://m.vk.com/@712772904-94399
https://m.vk.com/@712772904-94400
https://m.vk.com/@712772904-94401
https://m.vk.com/@712772904-94402
https://m.vk.com/@712772904-94403
https://m.vk.com/@712772904-94404
https://m.vk.com/@712772904-94405
https://m.vk.com/@712772904-94406
https://m.vk.com/@712772904-94407
https://m.vk.com/@712772904-94408
https://m.vk.com/@712772904-94409
https://m.vk.com/@712772904-94410
https://m.vk.com/@712772904-94411
https://m.vk.com/@712772904-94412
https://m.vk.com/@712772904-94413
https://m.vk.com/@712772904-94414
https://m.vk.com/@712772904-94415
https://m.vk.com/@712772904-94416
https://m.vk.com/@712772904-94417
https://m.vk.com/@712772904-94418
https://m.vk.com/@712772904-94419
https://m.vk.com/@712772904-94420
https://m.vk.com/@712772904-94421
https://m.vk.com/@712772904-94422
https://m.vk.com/@712772904-94423
https://m.vk.com/@712772904-94424
https://m.vk.com/@712772904-94425
https://m.vk.com/@712772904-94426
https://m.vk.com/@712772904-94427
https://m.vk.com/@712772904-94428
https://m.vk.com/@712772904-94429
https://m.vk.com/@712772904-94430
https://m.vk.com/@712772904-94431
https://m.vk.com/@712772904-94432
https://m.vk.com/@712772904-94433
https://m.vk.com/@712772904-94434
https://m.vk.com/@712772904-94435
https://m.vk.com/@712772904-94436
https://m.vk.com/@712772904-94437
https://m.vk.com/@712772904-94438
https://m.vk.com/@712772904-94439
https://m.vk.com/@712772904-94440
https://m.vk.com/@712772904-94441
https://m.vk.com/@712772904-94442
https://m.vk.com/@712772904-94443
https://m.vk.com/@712772904-94444
https://m.vk.com/@712772904-94445
https://m.vk.com/@712772904-94446
https://m.vk.com/@712772904-94447
https://m.vk.com/@712772904-94448
https://m.vk.com/@712772904-94449
https://m.vk.com/@712772904-94450
https://m.vk.com/@712772904-94451
https://m.vk.com/@712772904-94452
https://m.vk.com/@712772904-94456
https://m.vk.com/@712772904-94457
https://m.vk.com/@712772904-94458
https://m.vk.com/@712772904-94459
https://m.vk.com/@712772904-94460


0 回复 有任何疑惑可以回复我~

Teacher维护关联关系的话,就意味着Student要放弃关联维护,所以需要在Student的映射文件中<set>中设置 inverse = true,让Student放弃关联维护;

同样的,既然是Teacher来维护关联关系,那么就应该在Teacher的映射文件的<set>中设置cascade,让Teacher维护。


0 回复 有任何疑惑可以回复我~
#1

ypcFly 提问者

cascade哪方维护关联关系在哪方的映射文件配置!inverse属性在维护关联关系的一方设置为false,不维护关联关系的设置为true,是这样吗??
2017-08-01 回复 有任何疑惑可以回复我~
#2

慕侠_Ives 回复 ypcFly 提问者

many-to-many关联关系中,一端设置inverse=”false”,另一端设置为inverse=”true”。 one-to-many关联关系中,让one端设置inverse=”true”,由多端来维护关系表。根据需求,两张表都可以设置cascade,但一般不建议使用,尤其是delete。
2017-08-01 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Hibernate初探之多对多映射
  • 参与学习       23322    人
  • 解答问题       18    个

Hibernate中多对多关联映射的配置,多对多关联关系的应用场景

进入课程

关于inverse 和cascade属性的问题

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信