I have a PostgreSQL table and a data class representing the table. I am using annotations for mapping instead of mapping xml files. I deleted some columns as they are not required from both the db table and mapping class. But I get a runtime hibernate exception: missing column on the deleted columns. The columns are not referenced anywhere else, otherwise the compile would have failed. For now I added the columns back to the table (but not the class) and it works fine. Can anybody point the direction? I can post the code if you want but t is just a simple data class and a table.
Exception:
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'phaseRepository' defined in Servle
tContext resource [/WEB-INF/context/spring-entity.xml]: Cannot resolve reference to bean 'sessionFactory' while setting be
an property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating
bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/context/spring-entity.xml]: Invocation of init method failed; nested exception is
org.hibernate.HibernateException: Missing column: patient_given_name in public.patient_detail at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResol
ver.java:328) at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionVal
ueResolver.java:106)
Entity Class:
@Entity
@Table(name = "patient_detail")
public class PatientDetail implements Serializable {
private static final long serialVersionUID = -7765251798211029654L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "patient_detail_id_seq")
@SequenceGenerator(name = " patient_detail_id_seq ", sequenceName = " patient_detail_id_seq ", allocationSize = 1)
private long id;
@Column(name = " templateId ")
private long templateId;
@Column(name = "description")
private String description;
@Column(name = "anatomical_name")
private String anatomicalName;
@Column(name = "additional_comments")
private String additionalComments;
@Column(name = "create_date")
private Date createDate;
@Column(name = "modified_date")
private Date modifiedDate;
@ManyToOne
@ForeignKey(name = "fk_patient_id")
@JoinColumn(name = "patient_id")
private Patient patient;
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
@JoinColumn(name = "patient_id")
private List<PatientPhase> phases;
.....
getters and setters