[ https://issues.apache.org/jira/browse/DELTASPIKE-606?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Thomas Hug resolved DELTASPIKE-606. ----------------------------------- Resolution: Fixed > Simplified DTO mapping for Entity updates > ----------------------------------------- > > Key: DELTASPIKE-606 > URL: https://issues.apache.org/jira/browse/DELTASPIKE-606 > Project: DeltaSpike > Issue Type: Improvement > Components: Data-Module > Reporter: Thomas Hug > Assignee: Thomas Hug > Fix For: 0.8 > > > Updating a DTO currently still requires custom code in a mapper. This should > be reduced to a minimum in the mapper base class. > SimpleQueryInOutMapperBase: > {code:java} > @Inject > private QueryInvocationContext context; > protected abstract Object getPrimaryKey(Dto dto); > protected E findEntity(Object pk) > { > return (E) context.getEntityManager().find(context.getEntityClass(), pk); > } > @Override > public Object mapParameter(final Object parameter) > { > Object pk = getPrimaryKey((Dto) parameter); > if (pk != null) > { > E entity = findEntity(pk); > return toEntity(entity, (Dto) parameter); > } > return toEntity(newEntity(), (Dto) parameter); > } > {code} > Note that this is an API breaking change (toEntity). -- This message was sent by Atlassian JIRA (v6.2#6252)