org.hibernate.MappingException:类型不支持 ENVER

发布于 2024-10-19 08:17:30 字数 2093 浏览 6 评论 0 原文

当我引入复合主键时,我刚刚开始收到此错误。有什么理想的原因吗?我一直没有成功地试图解决这个问题。

Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.SerializableType
    at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addIdProperties(IdMetadataGenerator.java:71)
    at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addId(IdMetadataGenerator.java:107)
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:380)
    at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:102)
    at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
    at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
    at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:315)
    at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
    at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
    at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)

更新编辑 - 1

使用 Hibernate 3.3.1(随 JBoss 5.1 一起提供)以及 Spring MVC 2.5.6 和 jboss-envers 1.2.2GA。

波乔:

@Entity
@Table(name="program_store_rel")
@Audited
public class ProgramStoreRel extends MappedModel implements Serializable
{

  @EmbededId
  private ProgramStoreRelPK psRelPK;

  .
  .
  .
}

@Embeddable
public class ProgramStoreRelPK implements Serializable
{
  /**
 * Identifies the store that this item belongs to
 */
  @OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
  @JoinColumn(name="store_id",nullable=false,updatable=true,insertable=true)
  private Store store;

  /**
   * Identifies the program that this item belongs to
   */
  @OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
  @JoinColumn(name="program_id",nullable=false,updatable=true,insertable=true)
  private Program program;
 .
 .
}  

I just started getting this error when I introduced a composite primary key. Any ideal as to why? I have been unsuccessful in trying to figure this out.

Caused by: org.hibernate.MappingException: Type not supported: org.hibernate.type.SerializableType
    at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addIdProperties(IdMetadataGenerator.java:71)
    at org.hibernate.envers.configuration.metadata.IdMetadataGenerator.addId(IdMetadataGenerator.java:107)
    at org.hibernate.envers.configuration.metadata.AuditMetadataGenerator.generateFirstPass(AuditMetadataGenerator.java:380)
    at org.hibernate.envers.configuration.EntitiesConfigurator.configure(EntitiesConfigurator.java:102)
    at org.hibernate.envers.configuration.AuditConfiguration.<init>(AuditConfiguration.java:86)
    at org.hibernate.envers.configuration.AuditConfiguration.getFor(AuditConfiguration.java:99)
    at org.hibernate.envers.event.AuditEventListener.initialize(AuditEventListener.java:315)
    at org.hibernate.event.EventListeners$1.processListener(EventListeners.java:198)
    at org.hibernate.event.EventListeners.processListeners(EventListeners.java:181)
    at org.hibernate.event.EventListeners.initializeListeners(EventListeners.java:194)

Update Edit - 1

Using Hibernate 3.3.1 (Shipped with JBoss 5.1) along with Spring MVC 2.5.6 and jboss-envers 1.2.2GA.

POJO:

@Entity
@Table(name="program_store_rel")
@Audited
public class ProgramStoreRel extends MappedModel implements Serializable
{

  @EmbededId
  private ProgramStoreRelPK psRelPK;

  .
  .
  .
}

@Embeddable
public class ProgramStoreRelPK implements Serializable
{
  /**
 * Identifies the store that this item belongs to
 */
  @OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
  @JoinColumn(name="store_id",nullable=false,updatable=true,insertable=true)
  private Store store;

  /**
   * Identifies the program that this item belongs to
   */
  @OneToOne(fetch=FetchType.LAZY, cascade=CascadeType.ALL)
  @JoinColumn(name="program_id",nullable=false,updatable=true,insertable=true)
  private Program program;
 .
 .
}  

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此刻的回忆 2024-10-26 08:17:30

显然这是这个版本的 JBoss Envers 中的一个错误(请参阅 ENVERS-76 )。 Hibernate Envers 中报告了类似的问题 (HHH-4751 )并在版本 4.1.7 中修复。

不幸的是,建议的解决方法是避免复合 id。

Apparently this is a bug in this version of JBoss Envers (see ENVERS-76). A similar issue was reported in Hibernate Envers (HHH-4751) and fixed in version 4.1.7.

Unfortunately, the suggested workaround is to avoid composite ids.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文