-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Why 'column' annotation is ignored?
PostPosted: Wed Aug 17, 2011 2:51 am 
Beginner
Beginner

Joined: Thu Jun 24, 2010 2:30 am
Posts: 23
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.