1

我正在使用 Spring-Data-JPA 和 EclipseLink 开发一个多租户(多模式)应用程序。当不使用多租户功能时,一切正常,JPA 实体作为一种魅力,显然只适用于一个模式。当我尝试激活多租户时,将以下注释添加到实体:

@Multitenant(value=MultitenantType.TABLE_PER_TENANT)
@TenantTableDiscriminator(type=TenantTableDiscriminatorType.SCHEMA, contextProperty="eclipselink-tenant.id")

我重新启动应用程序,我得到以下异常:

Caused by: java.lang.IllegalArgumentException: No @IdClass attributes exist on the IdentifiableType [EntityTypeImpl@15818739:CrsMomiJob [ javaType: class com.gpdati.momi.model.core.CrsMomiJob descriptor: RelationalDescriptor(com.gpdati.momi.model.core.CrsMomiJob --> [DatabaseTable(CRS_MOMI_JOB)]), mappings: 7]].  There still may be one or more @Id or an @EmbeddedId on type.
at org.eclipse.persistence.internal.jpa.metamodel.IdentifiableTypeImpl.getIdClassAttributes(IdentifiableTypeImpl.java:169)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$IdMetadata.<init>(JpaMetamodelEntityInformation.java:170)
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:71)
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:146)
at com.gpdati.momi.jpa.MultiTenantJpaRepositoryFactory.getTargetRepository(MultiTenantJpaRepositoryFactory.java:30)
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:67)
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:136)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153)
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 79 more

似乎不再从寻找 @IdClass 注释的 Spring-Data 中读取 Id 字段上的 @Id 注释(我认为使用复合主键时需要 @IdClass 注释,这不是我的情况)

有什么线索吗?谢谢!

这里是完整的实体代码:

@Entity
@Table(name="CRS_MOMI_JOB")
@Multitenant(value=MultitenantType.TABLE_PER_TENANT)
@TenantTableDiscriminator(type=TenantTableDiscriminatorType.SCHEMA, contextProperty="eclipselink-tenant.id")
public class CrsMomiJob implements Serializable {
private static final long serialVersionUID = -432489894772L;

private String abilitata;

@Column(name="HOT_CODICE")
private String hotCodice;

@Column(name="INT_CODICE")
private String intCodice;

private Long intervallo;

private String note;

private String parametri;

@Id
private BigDecimal id;      

public CrsMomiJob() {
}

... all getters and setters ...

}
4

1 回答 1

1

似乎是 hasSingleIdAttribute() 中的 EclipseLink 元模型代码中的一个错误,它返回 true(因为 id 是多租户的复合),但这应该被隐藏,所以应该返回 false。

请记录一个错误。

于 2013-08-13T12:46:44.630 回答