2
I have three classes, Person, Client and Address, being Customer Person’s child and Address adding Person.
Segue Pessoa:
@Entity
public abstract class Pessoa implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private long id;
private String nome;
private String cpf;
private String email;
private String pw;
private String numeroEnd;
private String complementoEnd;
@OneToOne
public Endereco endereco;
Follows Address:
@Entity
public class Endereco implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
private long id;
private String cep;
private String logradouro;
private String bairro;
private String cidade;
private String uf;
@OneToOne(mappedBy = "post", cascade = CascadeType.ALL, orphanRemoval = true)
private Pessoa pessoa;
The mistake I’m having is this::
Exception Description: An Exception was thrown while Searching for persistence Archives with Classloader: Webappclassloader (delegate=true; repositories=WEB-INF/classes/) Internal Exception: javax.persistence.Persistenceexception: Exception [Eclipselink-28018] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.Entitymanagersetupexception Exception Description: Predeployment of Persistenceunit [Lojagamespu] failed. Internal Exception: Exception [Eclipselink-7154] (Eclipse Persistence Services - 2.6.1.v20150605-31e8258): org.eclipse.persistence.exceptions.Validationexception Exception Description: The attribute [pessoa] in Entity class [class br.com.lojagames.model.Endereco] has a mappedBy value of [post] which does not exist in its Owning Entity class [class br.com.lojagames.model.Pessoa]. If the Owning Entity class is a @Mappedsuperclass, this is invalid, and your attribute should Reference the correct subclass.
I am a layman in JPA but I would like to do to gain experience, however I believe I did the relationship between the classes in JPA in the wrong way, could point out me the error?
@Exactly, I did and it worked, thank you very much, Paul, it helped me a lot!
– G. Falcão