Code des
Code des

Reputation: 31

Hibernate doesn't add new columns to tables on hbm2ddl.auto="update"

Dears,

I have multiple tables and I need to add extra columns in each, I added them entity classes but hibernate stilldoesn't create them, I even tried to use the added columns in hql queries but it gives an error that property doesn't exist.

Columns I want to add:

@Column (name = "CREATED_BY")
    private String createdBy;

    private String active;

I retrieved an object and tried to print the value of active. it said this propery doesn't exist.

#{obj.active}

Upvotes: 2

Views: 2220

Answers (2)

Isaac_Zhu
Isaac_Zhu

Reputation: 105

@Code des It just hit me. Did you happen to forget the setters for the new fields? If that is the case, try to add the setters for the fields (maybe also getters). Make those private if you don't want other business logic to change the fields. Also, you mentioned you're using Hibernate 3 and there's no @CreationTimeStamp(I haven't got time to check if that's true), then I wonder how come you didn't get compile error when using an unexisting annotation??

Upvotes: 1

Gaurav Shakya
Gaurav Shakya

Reputation: 121

You have not added hibernate property to active variable

@Column (name = "active")

private String active;

Upvotes: 0

Related Questions