This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Correct usage of @AttributeOverride on embedded class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Correct usage of @AttributeOverride on embedded class" Watch "Correct usage of @AttributeOverride on embedded class" New topic
Author

Correct usage of @AttributeOverride on embedded class

John Summers
Ranch Hand

Joined: Oct 06, 2003
Posts: 125
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

Joined: Oct 06, 2003
Posts: 125
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
 
wood burning stoves
 
subject: Correct usage of @AttributeOverride on embedded class
 
Similar Threads
How to map a class that has an object that is defined as @Embeddable
JPA entities -- org.hibernate.TypeMismatchException
Polymorphism and relationships - JPA
HibernateTools Generating Wrong Code
ERROR [AbstractFlushingEventListener] Could not synchronize database state with session