Question

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.

Was it helpful?

Solution

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top