I've started new hibernate project yesterday. It is 4th project I use Hibernate so I'm not an expert, but I have a basic knowlege of Hibernate. At the start I've updated my hibernate jars from 3.5.1.Final to 3.6.6.Final nad created class for test. Here is it:
Code:
import javax.persistence.*;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import anyclip.data.hibernate.model.base.BaseEntity;
import anyclip.data.hibernate.model.base.BaseEntityImpl;
@Entity
@Table(name = "Title_Metadata_Attributes")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class TitleMetadataAttribute extends BaseEntityImpl implements BaseEntity {
private static final long serialVersionUID = -8803638643511991238L;
@Id @GeneratedValue(strategy = GenerationType.AUTO)
@Column( name="Title_Metadata_Attribute_ID", unique = true, nullable = false, updatable = false)
public Long getId() { return super.getId(); }
@Column( name="Metadata_Value" )
public String getValue() { return value; }
public void setValue(String value) { this.value = value; }
private String value;
@Column(name = "Title_Metadata_Category_ID", nullable = false)
public Long getCategory() { return category; }
public void setCategory(Long category) {
this.category = category;
}
private Long category;
@Column(name="HitCount")
public Integer getHitCount() { return hitCount; }
public void setHitCount(Integer hitCount) { this.hitCount = hitCount; }
private Integer hitCount;
}
Since it is simple test class I've supposed that all things working, buty I have "Invalid column name 'hit_count'." exception. It seems that Hibernate ignores 'Column' annotation. I've tried to move the annotation before 'setHitCount()' or before attribute 'hitCount' itself. It does't help. Changing naming starategy from 'Improved' to 'Default' works, but most of DB columns match 'Improved' stategy. Can anybody, explain to me, why column annotation is working for other fields of the class, but not for hitCount?