Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@Column annotation is ignored in Embedded object:Hibernate

 
Vimal Kumar Venugopal
Ranch Hand
Posts: 43
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Ranchers,

I have been trying out a few Hibernate sample programs and encountered the following problem:

I have an embedded object,


And the Entity object using this class is,


And the hibernate.cfg.xml as,


There is no error and the inserts are working fine. But while the @Column name is picked up from the entity class, the @Column from the embedded class seems to get ignored.

If you could help me out, I would be greatly privileged!

Thanks a ton
 
Subho Pramanik
Greenhorn
Posts: 14
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vimal,
your code looks fine however make sure that you are using the @Id annotation on the variable only and not on getter method of the Entity object.
If you are using @Id in the getter then all the annotations(@Column) must be put on the getters of the attributes(irrespective of whether the attribs are of Entity or Embedded object) i.e. if you are using @ID at the getter method make the @Column on getters of other attributes and if on field then use @Column on fields only.

I faced the same issue.
Try this, it will work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic