• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

@Column annotation is ignored in Embedded object:Hibernate

 
Ranch Hand
Posts: 43
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 14
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic