code: void insert(boolean readOnly, int generation) throws PersistException {
          if (mAllProperties == null) {
              throw new IllegalStateException();
          }
  
          mStoredLayout.setGeneration(generation);
  
          if (readOnly) {
              return;
          }
  
          try {
              mStoredLayout.insert();
          } catch (UniqueConstraintException e) {
              // If existing record logically matches, update to allow replication.
              StoredLayout existing = mStoredLayout.prepare();
              mStoredLayout.copyPrimaryKeyProperties(existing);
              try {
                  existing.load();
              } catch (FetchException e2) {
                  throw e2.toPersistException();
              }
              if (existing.getGeneration() != generation ||
                  !existing.getStorableTypeName().equals(getStorableTypeName()) ||
                  !Arrays.equals(existing.getExtraData(), mStoredLayout.getExtraData()))
              {
                  throw e;
              }
              mStoredLayout.setVersionNumber(existing.getVersionNumber());
              mStoredLayout.update();
          }
  
          for (LayoutProperty property : mAllProperties) {
              property.insert();
          }
      }
docs: Assumes caller is in a transaction.