2

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

@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") 时。但我不明白在这种情况下会发生什么。

有人可以告诉我发生了什么以及如何解决它吗?

4

0 回答 0