I have the following (partial) hierarchy:
@MappedSuperclass public abstract class PersistentEntity { @Id @GeneratedValue(generator="system-uuid") @Type(type = "pg-uuid") public UUID getId() { return id; } }
@Entity @Inheritance (strategy = InheritanceType.JOINED) @DiscriminatorColumn (name = "TYPE", discriminatorType = DiscriminatorType.STRING) public abstract class AbstractCredential extends PersistentEntity {// content}
@Entity @DiscriminatorValue ("Standard") @PrimaryKeyJoinColumn (name = "ID") public class StandardCredential extends AbstractCredential {// hashcode and quals here, by full data}
AbstractCredential is an object instead of @MappedSuperclass, so I can select it from id and get the corresponding "specific" class. my problem is that if I create a new (separate) instance with the identifier of an existing instance and then pass this separate instance to merge, hibernate creates a new object (which means that it generates a new identifier and overrides the id field in my newly created instance ) in my understanding, hibernate had to override all fields in an existing instance with values in a separate instance.
what am I doing wrong?
radai source share