Given my classes where Encomenda
inherits from Objeto
:
@Entity
@Table(name = "objeto")
@XmlRootElement(name = "objeto")
@XmlAccessorType(XmlAccessType.FIELD)
@AllArgsConstructor
@NoArgsConstructor
public class Objeto implements Serializable{
private static final long serialVersionUID = 1L;
@Getter
@Setter
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Getter
@Setter
@Pattern(regexp = "[A-z]{2}\d{9}[A-z]{2}", message = "O código não é válido")
@Size(min = 13, max = 13, message = "Apenas 13 caracteres")
@Column(nullable = false, length = 13, unique = true)
@NotBlank(message = "Nome não pode estar em branco")
@XmlElement(name = "numero")
private String codigo;
@Getter
@Setter
@XmlElement(name = "evento")
@OneToMany(mappedBy = "objeto", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
private List<Evento> eventos;
@Getter
@Setter
@XmlElement
@Column
private String erro;
}
Order:
@Entity
@EqualsAndHashCode(callSuper = true)
@AllArgsConstructor
@NoArgsConstructor
public class Encomenda extends Objeto {
private static final long serialVersionUID = 1L;
@Getter
@Setter
@Column
@XmlTransient
private String local;
@Getter
@Setter
@Column
@XmlTransient
private String descricao;
@Getter
@Setter
@Column
@XmlTransient
private String evento;
@Getter
@Setter
@Column
@XmlTransient
private String loja;
@Getter
@Setter
@Column
@XmlTransient
private Timestamp horaEvento;
@Getter
@Setter
@Column
@XmlTransient
private String situacao;
}
What is happening is that when tables are created in the database, the object table has all the order fields, how can I correct them? I want only the fields of the Object class in the object table. Now the order table I want fields of both classes, so far so good, what I need is to replicate the same values that are in object in the order fields, how to do?