hibernate @JoinColumnsOrFormulas注释@id

时间:2011-08-31 08:33:16

标签: java hibernate

我有2个id的实体,其中一个有注释@JoinColumnsOrFormulas

@AccessType("property")
@Id
@NotFound(action=NotFoundAction.IGNORE)
@ManyToOne(optional = false, fetch = FetchType.LAZY)
@JoinColumnsOrFormulas({
        @JoinColumnOrFormula( column=@JoinColumn(name="RE",  referencedColumnName="ret")),
        @JoinColumnOrFormula( formula=@JoinFormula(value="ret2", referencedColumnName="rete"))
})
@Fetch(FetchMode.SELECT)
private rete ret;

但它会引发异常:

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource... Invocation of init method failed; nested exception is java.lang.ClassCastException: org.hibernate.mapping.Formula cannot be cast to org.hibernate.mapping.Column
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:502)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:84)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:282)

使用@JoinColumnsOrFormulas ???

无法使用@id注释

0 个答案:

没有答案