Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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
share|improve this question
1  
looks like your your entity class still has the field which points to the column, did u try deleting that? –  sanbhat Jun 10 '13 at 16:01
    
yes I deleted all the deleted columns from the entity class. And I verified it several times –  roadster Jun 10 '13 at 16:04
    
can you post ur entity class and the exception? –  sanbhat Jun 10 '13 at 16:05
    
just updated the question with exception and code –  roadster Jun 10 '13 at 16:28
    
Notice patient_given_name in public.patient_detail in the exception which is not there in the table as well as the class. –  roadster Jun 10 '13 at 16:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.