Uploaded image for project: 'Hibernate ORM'
  1. Hibernate ORM
  2. HHH-11514

Id is generated on replicated instead of using the one provided

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 4.2.0.Final
    • Fix Version/s: None
    • Component/s: hibernate-core
    • Labels:
      None
    • Environment:
      Hibernate + JPA. EJB interface.
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Worked in:
    • backPortable:
      Backport?
    • Suitable for new contributors:
      Yes, likely
    • Last commented by a user?:
      true

      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
        */

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                Time Tracking

                Estimated:
                Original Estimate - 2h
                2h
                Remaining:
                Remaining Estimate - 2h
                2h
                Logged:
                Time Spent - Not Specified
                Not Specified