Class SchemaReport

java.lang.Object
com.codename1.orm.session.SchemaReport

public final class SchemaReport extends Object

What Session.schemaReport() found when it compared the registered mappings with the tables that already exist. Reading it changes nothing in the database.

Every difference is one of three kinds, because they call for different fixes:

  • SchemaReport.Kind.MIGRATION_REQUIRED: the mapping is fine, the schema is behind it -- a table or column is missing. A migration brings the database to the mapping.
  • SchemaReport.Kind.UNSUPPORTED: the existing column cannot hold what the mapping would write, or a key the mapping does not know identifies the rows. Data would be misread or refused, so the mapping has to change -- a different storage type, @Temporal for a native timestamp, an explicit @Column name -- or the column has to be converted deliberately.
  • SchemaReport.Kind.CONSTRAINT_MISMATCH: a column's nullability differs from the mapping. Rows still read and write, but the database accepts a null the mapping cannot hold, or refuses one it can. A schema that is deliberately stricter than the mapping is legitimate, which is why this is kept apart.
SchemaReport report = session.schemaReport();
for (SchemaReport.Issue issue : report.getIssues()) {
    Log.p(issue.getKind() + " " + issue.getTable() + "." + issue.getColumn()
            + ": " + issue.getMessage());
}
  • Constructor Details

    • SchemaReport

      public SchemaReport(List<SchemaReport.Issue> issues)
      Creates a report holding issues, in the order they were found.
      Parameters:
      issues - the differences found; copied
  • Method Details

    • isCompatible

      public boolean isCompatible()
      True when the existing schema matches every mapping.
    • getIssues

      public List<SchemaReport.Issue> getIssues()
      Every difference found, unmodifiable.
    • getIssues

      public List<SchemaReport.Issue> getIssues(SchemaReport.Kind kind)
      The differences of one kind.
      Parameters:
      kind - the kind to select
      Returns:
      the matching issues, in the order they were found
    • toString

      public String toString()
      A multi-line summary: unsupported mappings first, then required migrations, then constraint differences.
      Overrides:
      toString in class Object