Finally, I've been able to solve the problem. There weren't any problems with the mappings I presented in both classes. Those mappings I showed about Proyecto and Incidencia were different before. The class Incidencia used a compound primary key with an Id class:
@Entity
@Table(name = "INCIDENCIAS")
@IdClass(IncidenciaKey.class)
public class Incidencia implements Serializable {
@Id
@Column(name = "ID")
private Integer id;
@Id
@Column(name = "ID_PROYECTO", nullable = false, insertable = false, updatable = false)
private Long idProyecto;
@ManyToOne(cascade = CascadeType.PERSIST)
@NotNull
@Valid
private Proyecto proyecto;
...
}
I only renamed this old version of Incidencia, so there were two classes with @Table(name = "INCIDENCIAS"). I suppose this was the mistake. There was still a column named "PROYECTO" in the in-memory database that it came from this renamed and, as I thought incorrectly, unused entity.
As soon as I moved the renamed Incidencia class out of the package from the database is built everything worked properly.
I want to apoligise for asking this inaccurate question.
Thank you for your help.