[ https://issues.apache.org/jira/browse/ISIS-1562?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Daniel Keir Haywood updated ISIS-1562: -------------------------------------- Summary: Metamodel exception if @DomainObject(ENTITY) missing when @PersistenceCapable or @Entity (was: @DomainObject(ENTITY) req'd if @PersistenceCapable) > Metamodel exception if @DomainObject(ENTITY) missing when @PersistenceCapable > or @Entity > ---------------------------------------------------------------------------------------- > > Key: ISIS-1562 > URL: https://issues.apache.org/jira/browse/ISIS-1562 > Project: Isis > Issue Type: Improvement > Components: Isis Applib (programming model) > Affects Versions: 1.13.2 > Reporter: Daniel Keir Haywood > Priority: Minor > > Metamodel validator if forget to annotate... > > Also, RepositoryService#persist(...) is a no-op if the domain object passed > in is not an entity; this should probably fail-fast. > This was originally prompted by an obscure message being thrown in > Memento#updateFieldsAndResolveState(...), as the result of an entity being > treated as transient, because (a) the @PersistenceCapable annotation was > accidentally omitted, and (b) a call to RepositoryService#persist(...) just > did nothing. > So, this ticket would be a fail-fast for that scenario. > {code:java} > private void updateFieldsAndResolveState(final ObjectAdapter > objectAdapter, final Data data) { > > boolean dataIsTransient = data.getOid().isTransient(); > > if (!dataIsTransient) { > ... > } else if (objectAdapter.isTransient() && dataIsTransient) { > ... > > } else if (objectAdapter.isParentedCollection()) { > ... > > } else { > // THIS IS THE BRANCH THAT'S TRIGGERED IF @PersistenceCapable IS > ACCIDENTALLY OMITTED. > final ObjectData od = (ObjectData) data; > if (od.containsField()) { > throw new IsisException("Resolve state (for " + objectAdapter > + ") inconsistent with fact that data exists for fields"); > } > } > } > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)