无法获得SINGLE_TABLE继承在Spring Roo中工作。

时间:2013-08-29 01:12:07

标签: spring hibernate spring-roo

我正在使用Spring Roo with Oracle来使用SINGLE_TABLE继承来映射继承层次结构。 Roo数据库逆向工程创建了这个类。我添加了@Discriminator ... annotations和inheritanceType。

@RooDbManaged(automaticallyDelete = true)
@RooJpaActiveRecord(inheritanceType = "SINGLE_TABLE", table = "MEASUREMENT", schema = "SCREENING", sequenceName = "MEASUREMENT_SEQ")
@DiscriminatorColumn(name = "DTYPE", discriminatorType = DiscriminatorType.STRING, length = 50)
@DiscriminatorValue("TEXT")
public class Measurement {
    ...
}

Roo用

建立了Measurement_Roo_DbManaged.aj
privileged aspect Measurement_Roo_DbManaged {
    ...
    @Column(name = "DTYPE", length = 50)
    @NotNull
    private String Measurement.dtype;
    ...
}

和Measurement_Roo_Jpa_Entity.aj与

declare @type: Measurement: @Inheritance(strategy = InheritanceType.SINGLE_TABLE);

(如果你对Roo不太熟悉,这些位在编译之前会被折叠到主类中。)

然后我创建了子类

@Entity
@DiscriminatorValue(value="NUMERIC")
public class MeasurementNumeric extends Measurement {
    public MeasurementNumeric(Long value) {
        setNumericValue(value);
    }
}

现在,每当我启动应用程序时,它会在上下文初始化时抛出BeanCreationException,最终由

引起
org.hibernate.MappingException: Repeated column in mapping for entity: my.package.domain.MeasurementNumeric column: DTYPE (should be mapped with insert="false" update="false") 
    at org.hibernate.mapping.PersistentClass.checkColumnDuplication(PersistentClass.java:682)

我一直想弄清楚这里发生了什么,我无处可去。我见过这个错误的唯一其他时间是有人同时在多个属性上声明@Column(name =“someName”)。但我不知道在这种情况下会发生什么情况。

有人能告诉我发生了什么以及如何解决这个问题吗?

0 个答案:

没有答案