Main Content

Resolve Issues with Object Relational Mapping

This table describes how to address common errors you might encounter while working with ORM methods.

Error MessageProbable CauseSolution
Persisted properties must have public access or provide set and get access to database.relational.connection.

The Database Toolbox™ connection object needs access to the properties mapped to the database in order to read and write them properly.

For any properties without the ExcludeFromDatabase attribute, set the access to one of the following:

  • Public

  • ?database.relational.connection

Mappable requires at least one property to have the PrimaryKey attribute.

ORM requires that you specify the primary key as the link between a MATLAB® object and its corresponding entry in a database table.

Add a property with the PrimaryKey attribute. You can add the AutoIncrement attribute instead of specifying the PrimaryKey value.

Unknown AutoIncrement syntax for myVendor.

Database Toolbox does not have information on how to create the autoincrementing keys for this vendor.

Use the execute function to create the table with an SQL query.

AutoIncrement properties cannot be written to the database with specified values. Set the property to an empty or missing value to allow the database to set the value automatically.

The ormwrite method does not support inserting known values to an autoincrementing primary key column. Inserting known values differs from vendor to vendor.

Set the value of the AutoIncrement property to an empty value to insert a new row into the database table.

Properties with the AutoIncrement attribute must also have the PrimaryKey attribute.

Database Toolbox supports the AutoIncrement attribute for properties that also have the PrimaryKey attribute.

If you want the property with the AutoIncrement attribute to also be a primary key, add the PrimaryKey attribute to it. If the property is not a primary key, remove the AutoIncrement attribute and set the value of the property manually.

AutoIncrement properties must have integer types.

A property with the AutoIncrement attribute was assigned a non-integer class validation.

Specify the class validation of the property as an integer type.

Unknown syntax to return inserted keys for Oracle.

Oracle® does not specify a syntax for retrieving the primary keys after rows have been inserted.

Do not specify an output to ormwrite when using autoincrementing values with Oracle ODBC. To access the values of inserted keys, use ormread with an appropriate RowFilter value to return your object to MATLAB.