Accessing Roo Identifier

那年仲夏 提交于 2020-01-17 03:03:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!