【问题标题】:Accessing Roo Identifier访问 Roo 标识符
【发布时间】:2014-05-10 09:35:20
【问题描述】:

我的这个实体类有多个主键 (@Id),这导致我使用了 @RooJpaActiveRecord(identifierType = '<IdentifierClass.class>')@RooIdentifier(dbManaged=true)。但是我在从实体类本身访问Identifier.class 时遇到问题。

我的问题是如何在不删除 @RooJpaActiveRecord(identifierType = '<Identifier.class>') 代码的情况下访问实体类中的 Identifier

【问题讨论】:

    标签: jpa spring-roo composite-key composite-primary-key


    【解决方案1】:

    Roo 将在您的实体上生成一个属性 id。此属性在 MyEntity_Roo_Jpa_Entity.aj 文件中声明(这包括一个 getter/setter)。所以,你简单的使用:

    
        MyEntity myEntity = new MyEntity();
        myEntity.setId(new Identifier());
        myEntity.getId().setPk1(value1);
        // ....
        // ....
        myEntity.getId().setPkn(valuen);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-26
      相关资源
      最近更新 更多