访问Roo标识符 [英] Accessing Roo Identifier

查看:126
本文介绍了访问Roo标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have this entity class having more than one primary key (@Id) which resulted me to use @RooJpaActiveRecord(identifierType = '<IdentifierClass.class>') and @RooIdentifier(dbManaged=true). Yet I am having a problem on accessing Identifier.class from the entity class itself.

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

My questions is how can I access Identifier in the entity class without, at most, removing the @RooJpaActiveRecord(identifierType = '<Identifier.class>') code.

推荐答案

Roo会在您的实体上生成属性 id .该属性在MyEntity_Roo_Jpa_Entity.aj文件中声明(包括getter/setter).因此,您的用法很简单:

Roo will generate a property id on your entity. This property is declared on MyEntity_Roo_Jpa_Entity.aj file (this includes a getter/setter). So, you simple use:


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

这篇关于访问Roo标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆