Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public final class SchemaReport

  1. Object
  2. SchemaReport

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:

  • 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.
  • 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.
  • 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());
}

Nested types

enum SchemaReport.KindHow an Issue is resolved.
class SchemaReport.IssueOne difference between a mapping and the existing schema.

Constructors

public SchemaReport(List<SchemaReport.Issue> issues)Creates a report holding issues, in the order they were found.

Methods

public boolean isCompatible()True when the existing schema matches every mapping.
public List<SchemaReport.Issue> getIssues()Every difference found, unmodifiable.
public List<SchemaReport.Issue> getIssues(SchemaReport.Kind kind)The differences of one kind.
public String toString()A multi-line summary: unsupported mappings first, then required migrations, then constraint differences.

Inherited methods

Constructor details

SchemaReport

public SchemaReport(List<SchemaReport.Issue> issues)
Creates a report holding issues, in the order they were found.

Parameters

issues List<SchemaReport.Issue>
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 SchemaReport.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.