Cannot update a Sub Entiy InheritanceType.JOINED and when specify and @IdClass

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Cannot update a Sub Entiy InheritanceType.JOINED and when specify and @IdClass



I am using the version 5.2.17.Final of Hibernate.



I have an entity Employee that extends the entity Person (below the two entities). When I try to update an instance of employee , the exception "Duplicate entry 'Test' for key 'PRIMARY' " is thrown.
When I remove the annotation @IdClass(value = PersonId.class) from the Entity Person, the update works fine.



When i debugged in hibernate, the entity Employee is always considered as transient when merging the object.



Can you please tell me why when I add @IdClass i cannot update a sub entity and the system will always try to invoke the insert ?


@Entity
@IdClass(value = PersonId.class)
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "persons")
@Access(value = AccessType.FIELD)
public class Person {

public Person() {
}

@javax.persistence.Column(name = "name", unique = false, nullable = false, insertable = true, updatable = false, length = 255)
@Id
@Basic(fetch = FetchType.EAGER, optional = false)
private String name;

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}


@Entity
@Table(name = "employees")
@Inheritance(strategy = InheritanceType.JOINED)
@Access(value = AccessType.FIELD)
public class Employee extends Person {

private String idEmployee ;


public String getIdEmployee() {
return idEmployee;
}

public void setIdEmployee(String idEmployee) {
this.idEmployee = idEmployee;
}
}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

How to scale/resize CVPixelBufferRef in objective C, iOS