I have the following structure: a contract, has several additives so I have my contract class and my additive class
In the contract class, I call it:
@OneToMany(mappedBy = "contrato", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
private List<Aditivo> aditivo;
I just need this list to be sorted by date field so I changed to
@OneToMany(mappedBy = "contrato", fetch = FetchType.EAGER, cascade = CascadeType.ALL)
@OrderBy("data ASC")
But when I do this it gives error
JBAS014777: Services which failed to start: service jboss.persistenceunit."contratos.war#contratos": org.jboss.msc.service.StartException in service jboss.persistenceunit."contratos.war#contratos": Failed to start service
I've tried @OrderBy (name="date") tb
MY ADDITIVE ENTITY: then have getters and setters
@Entity
@Table(name="aditivo",schema="contratos")
public class Aditivo implements Serializable{
private static final long serialVersionUID = 2379719760666156224L;
@Id
@GeneratedValue
private Long id;
@Column(length = 300)
private String tipo;
@Column
private Boolean pdf;
public Boolean getPdf() {
return pdf;
}
public void setPdf(Boolean pdf) {
this.pdf = pdf;
}
@Column
private Date data;
@Column(length = 300)
private String numero;
@Column(length = 500)
private String objeto;
@ManyToOne
@JoinColumn(name="contrato", referencedColumnName = "id")
private Contratos contrato;