Situation
I need to load some data into H2 database while testing phase. I placed SQL file data-h2.sql into src/test/resources
folder. File is found and executed. But problem occurs with my entity classes.
I have this base entity class:
@MappedSuperclass
public abstract class BaseEntity implements Persistable<Long> {
@Id
@Column(name = "id", updatable = false, nullable = false)
protected Long id;
@Override
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
@Override
public boolean isNew() {
return this.id == null;
}
}
and then concrete entities:
@Entity
@Table(name = "employees")
public class EmployeeEntity extends BaseEntity {
}
But while loading data in test entities are not constructed in "proper way", fields in base entity are not found. When I place these fields into concrete entities (e.g. Employee
) everything works.
Column "id" not found; SQL statement: ....
Question
Is there some way how to solve this issue? What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire