Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-1562

Metamodel exception if @DomainObject(ENTITY) missing when @PersistenceCapable or @Entity

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Abandoned
    • 1.13.2
    • None
    • None

    Description

      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.

          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");
                  }
              }
          }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: