Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Correct usage of @AttributeOverride on embedded class

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello chaps,

I am writing some small hibernate examples and the simple @AttributeOverride is 'doing my head in' (as we say in the UK). The code below gives the error
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'boringEntity_boringCode' in 'field list'
and I'm pretty sure this is because I'm using the @AttributeOverride wrong so hibernate is using the default name for the FK reference for BoringEntity, which won't work. Take a look:





And the tables are:

1_CompoundIdEntity2
-someCode
-boringEntityId

1_BoringEntity
-boringCode
-boringDesc

Any help appreciated. I don't find the documentation for this tag particularly revealing I'm afraid.
Cheers,
John
 
John Summers
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Solved!!

Silly me.. I forgot to add

@JoinColumn(name="boringEntityId")

beside the @OneToOne tag.If you don't put @JoinColumn then HB use the default name which is boringEntity_boringCode. No @AssociationOverride required.

Regards,
John
 
They worship nothing. They say it's because nothing is worth fighting for. Like this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic