2013-01-16 43 views
2

假設你有這樣映射的@Embeddable如何處理@Type上@AttributeOverrides

@Embeddable 
public class Wheel { 
    @Column(name = "COLOR") 
    @Type(type = "my.package.ColorUserType") 
    private Color theColor; 
} 

,並嘗試使用這樣的:

@Entity 
@Table(name = "CAR") 
public class Car { 
    @Embedded 
    @AttributeOverride(
    column = @Column(name = "STEERING_WHEEL_COLOR") 
    name = "theColor" 
) 
    private Wheel steeringWheel; 
} 

當我這樣做,我在啓動時會得到一個大胖子org.hibernate.MappingException: Could not determine type for: my.package.Color

那麼有沒有辦法來覆蓋類型或確保它使用@Embeddable中定義的類型,因爲當使用@AttributeOverride時顯然不會保留它?

回答