Model Class

Base class for persistence models generated by the javaxt-orm library.

Constructors

protected Model( String tableName )
protected Model( String tableName, java.util.HashMap fieldMap )

Methods

delete( ) returns void
Used to delete the model from the database.
equals( Object obj ) returns boolean
getID( ) returns Long
getTableName( javaxt.sql.Model model ) returns String
Returns the name of the table backing a given Model
hashCode( ) returns int
init( Class c, javaxt.sql.ConnectionPool connectionPool ) returns void
Used to initialize a Model and associate it with a database connection pool. This allows queries and other database metadata to be cached.
        for (Jar.Entry entry : jar.getEntries()){
            String name = entry.getName();
            if (name.endsWith(".class")){
                name = name.substring(0, name.length()-6).replace("/", ".");
                Class c = Class.forName(name);
                if (javaxt.sql.Model.class.isAssignableFrom(c)){
                    javaxt.sql.Model.init(c, database.getConnectionPool());
                }
            }
        }
    
init( javaxt.io.Jar jar, javaxt.sql.ConnectionPool connectionPool ) returns void
Used to initialize all the Models found in a jar file and associate them with a database connection pool. This allows queries and other database metadata to be cached.
save( ) returns void
Used to persist the model in the database.
setID( Long id ) returns void
setSchemaName( String schemaName, Class c ) returns void
Provides an option to override the default schema used by a model
toJson( ) returns javaxt.json.JSONObject
Returns a JSON representation of this model.