◐ Shell
clean mode source ↗

Model Class - JavaXT Core

JavaXT Documentation

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

Constructors

There are no public constructors.

Public Methods

setID( Long id ) returns void

save( ) returns void

Used to persist the model in the database.

delete( ) returns void

Used to delete the model from the database.

toJson( ) returns JSONObject

Returns a JSON representation of this model.

equals( Object obj ) returns boolean

Static Methods

init( Class c, 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, 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.

getTableName( Model model ) returns String

Returns the name of the table backing a given Model

setSchemaName( String schemaName, Class c ) returns void

Provides an option to override the default schema used by a model