java - Immutable Objects & Updates -


if i'm using immutable class named name stores people's names, , wants change name shouldn't name updated (essentially delete old entry , insert new entry)? appears contradict definition (by annotation) of immutable updating entity ignored. should if immutable class stored in database needs updated? should not mapped @immutable though immutable class?

the reference says:

when entity read-only:

  • hibernate does not dirty-check entity's simple properties or single-ended associations;
  • hibernate not update simple properties or updatable single-ended associations;
  • hibernate not update version of read-only entity if simple properties or single-ended updatable associations changed;

and says:

in ways, hibernate treats read-only entities same entities not read-only:

  • hibernate cascades operations associations defined in entity mapping.
  • hibernate updates version if entity has collection changes dirties entity;
  • a read-only entity can deleted.

so, think have delete() instance , save() again new name dirty-check not happen on read-only entities.

reference: read-only entities


Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -