Id is generated on replicated instead of using the one provided

Description

The system prefers to generate a new ID instead of using the one the programmer provides.
The replicate action doesn't say you will do that but the opposite. Use the id provided by programmer.

Offending code is:

final boolean regenerate = persister.isIdentifierAssignedByInsert(); // prefer re-generation of identity!
final EntityKey key = regenerate ? null : source.generateEntityKey( id, persister );

Even hibernate documentation says that:

/**

  • Persist the state of the given detached instance, reusing the current
    * identifier value. This operation cascades to associated instances if
    * the association is mapped with {@code cascade="replicate"}
    *
    * @param object a detached instance of a persistent class
    * @param replicationMode The replication mode to use
    */

Environment

Hibernate + JPA. EJB interface.

Assignee

Unassigned

Reporter

Gonzalo Aguilar Delgado

Fix versions

None

Labels

None

backPortable

Backport?

Suitable for new contributors

Yes, likely

Requires Release Note

None

Pull Request

None

backportDecision

None

Worked in

4.2.0.Final

Components

Affects versions

Priority

Major
Configure