问题
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.
My questions is how can I access Identifier
in the entity class without, at most, removing the @RooJpaActiveRecord(identifierType = '<Identifier.class>')
code.
回答1:
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);
来源:https://stackoverflow.com/questions/22754924/accessing-roo-identifier