Hibernate: Refresh, Evict, Replicate and Flush

后端 未结 3 1911
终归单人心
终归单人心 2020-11-30 21:43

I wish I knew what exactly does each item in this list, how it works, what the consequences and when is the correct time to use.

  1. Refresh
  2. Evict
3条回答
  •  Happy的楠姐
    2020-11-30 21:50

    replicate() is intended to be used instead of save()/persist() when you need to save an entity with a given identifier despite the fact that identifier of the said entity is configured to be generated.

    It's useful when some of the entities (perhaps coming from external systems) have pre-existing identifiers, whereas other entities of the same type need their identifiers to be generated.

    However, due to a long-standing bug in Hibernate (HHH-1459, HHH-2716) replicate() doesn't work as expected with some kinds of id generators. This problem limits usefullness of replicate() and requires you to implement unpleasant workarounds to emulate its behaviour if your id generator strategy is affected and you cannot change it.

提交回复
热议问题