Say you have an @Embeddable mapped like this:
@Embeddable
public class Wheel {
@Column(name = "COLOR")
@Type(type = "my.package.ColorUserType")
private Color theColor;
}
and you try to use it like this:
@Entity
@Table(name = "CAR")
public class Car {
@Embedded
@AttributeOverride(
column = @Column(name = "STEERING_WHEEL_COLOR")
name = "theColor"
)
private Wheel steeringWheel;
}
When I do this, I get a big, fat org.hibernate.MappingException: Could not determine type for: my.package.Color on startup.
So is there a way to override the type or make sure it uses the defined type in the @Embeddable since it’s obviously not being kept when the @AttributeOverride is used?
It looks like this can’t be done because it’s not a
Basictype mapping. Source: Java 6 API – AttributeOverride.