I implemented a semi-generateable solution, perhaps it helps.
add to DomainClass.groovy template
static @artifact.name@ getComposite(String compositeId)
{
return @artifact.name@.get(compositeId)
}
will be after generation
static Author getComposite(String compositeId)
{
return Author.get(compositeId)
}
in Controller.groovy template replace all Domainclass.get() by getComposite()
This will still work for non-composite. For composite PK implement the getComposite in addition to set/get ID and the generated views and controllers will work.
e.g.
void setId(String compositeId)
{
person.id = new Long(getPersonFromId(compositeId))
project.id = new Long(getProjectFromId(compositeId))
level.id = new Long(getLevelFromId(compositeId))
}
static String getPersonFromId(String compositeId)
{
return compositeId.substring(0,compositeId.indexOf("-"));
}
static String getProjectFromId(String compositeId)
{
return compositeId.substring(compositeId.indexOf("-")+1,compositeId.lastIndexOf("-"));
}
static String getLevelFromId(String compositeId)
{
return compositeId.substring(compositeId.lastIndexOf("-")+1);
}
String getId()
{
return person.id + "-" + project.id + "-" + level.id;
}
static UserRight getComposite(String compositeId)
{
return UserRight.get(
new UserRight(
person:Person.get(UserRight.getPersonFromId(compositeId)),
project:Project.get(UserRight.getProjectFromId(compositeId)),
level:AccessLevel.get(UserRight.getLevelFromId(compositeId))
)
);
}
Will this issue be planned for any future release?