Hibernate - update the primary key 'id' column in the table

前端 未结 6 1388
猫巷女王i
猫巷女王i 2021-01-18 06:35

In my Java applicaion, I am using hibernate .hbm file to access database; Is this possible to update the primary key \'id\' column in the table; Where the \'id\' column in m

6条回答
  •  执念已碎
    2021-01-18 06:52

    There is a workaround if you prefer to update via entity instead of query:

    1) clone the entity to a new entity.
    2) delete the old entity. (be careful of your cascade children entities)
    3) change the primary key of new entity (or set it null depend your generation strategy).
    4) save the new entity.
    

提交回复
热议问题