I have legacy code with class like
package org.test.jpa.entity;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
@MappedSuperclass
public class TestEntityBase {
private long id;
@Column(name = "id", updatable = false)
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
}
and I use 2 entities like
package org.test.jpa.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "table1")
public class TestEntity1 extends TestEntityBase {
private String name;
@Id
@Override
public long getId() {
return super.getId();
}
@Column(name="one_name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
package org.test.jpa.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "table2")
public class TestEntity2 extends TestEntityBase {
private String name;
@Id
@Override
public long getId() {
return super.getId();
}
@Column(name="two_name")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
JPA persistent unit failed to start with exception
On my opinion, the heart of the problem is the changes in
who prevents any persistent attribute annotations processing if this attribute has any one in @MappedSuperclass So, identity attributes count for such entity always will 0. |