My scenario is to make a copy of an entity that already has id of its own and all child entities
and insert it to db.
Asset existingAsset = getAssetFromDb(assetId); getSession().detach(existingAsset); Asset copyAsset = copyService.copyAsset(existingAsset); this.getSession().save(copyAsset);
and it fails due to the already defined ids that were copied from existingAsset.
If I call
this.getSession().saveOrUpdate(copyAsset); it just updates existing asset with copy, but not insert new record.
Is there any good way to solve the problem?