我有一个PostgreSQL表和一个表示该表的数据类。我使用注释来映射而不是映射xml文件。我删除了一些列,因为db表和映射类都不需要它们。但是我得到了一个运行时hibernate异常:删除已删除列上的列。列不会在其他任何地方引用,否则编译将失败。现在我将列添加回表(但不是类),它工作正常。任何人都可以指出方向吗?如果你愿意,我可以发布代码但是t只是一个简单的数据类和一个表。
例外:
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
@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