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.
The problem is the @Id generator strategy you’re using there. I suppose you are using an automatic identifier strategy like IDENTITY or SEQUENCE.
Because you are copying the id as well, Hibernate will think that you want to persist a new entity, but that entity already has an identifier.
Just make sure you skip the id in the cloned entity and leave it null. This way, Hibernate will see that you passed a transient entity and will persist it for you.