2

Could someone help me to set the proper way to override a column name in an extended entity.

Embedeable:

@Embedable
Email
@Column(name = "email_adress")
private string email;

Parent entity:

@Entity
AddressBook
@Embedded
@AttributeOverrides( {
        @AttributeOverride(name="email", column = @Column(name="email_address") )
} )
private Email email

Extending entity:

@Entity
@AttributeOverrides( {
        @AttributeOverride(name="email", column = @Column(name="home_email") )
} )
DeluxAddressBook extends AddressBook
@Embeded 
@AttributeOverrides( {
        @AttributeOverride(name="email", column = @Column(name="work_email") )
} )
private Email workEmail;

In the last entity I get workEmail mapped to "work_email" column which is OK, however home_email is mapped to column "email_address" defined originally in the embeddable. It should be mapped to a "home_email" column.

I tried w/o success:

@AttributeOverride(name="email.email", column = @Column(name="home_email") )

Thanks for your help, Jess

jessarah
  • 351
  • 1
  • 4
  • 13

1 Answers1

0

In the last mapping your both AttributeOverride name property defines mapping for email which is field from base class. Second mapping should be for workEmail not for email. With this change you should be able to achieve desired result.

Amit Deshpande
  • 19,001
  • 4
  • 46
  • 72
  • when I do what you suggest I get an org.hibernate.MappingException: Repeated column in mapping for entity: ...server.model.DeluxAddressBook column: email_address. This is just an excersize I tried. The work around we took was to create separate entities. – jessarah Mar 30 '12 at 13:49