com.zentense.step2.model
Class AutoModel

java.lang.Object
  extended by com.zentense.step2.model.ResultSetModel
      extended by com.zentense.step2.model.AutoModel
Direct Known Subclasses:
AutoI18NModel

public class AutoModel
extends ResultSetModel

An AutoModel is a ResultSetModel defined in the application model file, and automatically created and initialized by 2step. Instances of this object are obtained when using keyword model on 2step. For instance if you define a model called Customer in the application model file, the expression model.Customer returns an AutoModel.

AutoModels extends ResultSetModel by adding finders, which are defined in the application model file, and support compound primary keys. Finders are parametrized SQL queries (similar to prepared statements) that can be easily invoked from 2step: model.<name>::findById(<pk1>, ... , <pkn>) or a model.<name>::deleteById(<pk1>, ... , <pkn>). These two finders (findById and deleteById) are automatically generated by 2step (application model when compiled generates a file called ModelInit.java where all the AutoModels used in the application are initialized), but more finders can be defined in the application model file. From Java findById finder may be also invoked this way: find(vm, "findById", new Object[]{pk1, ... pkn})

Any AutoModel also includes a prepared statement for inserting (called insert) and updating (called update) all the rows (auto incremental identifiers are excluded from inserts). For instance insert prepared statement can be invoked from 2step with model.<name>::insert(<col1>, ... , <coln>) or from Java wit prepare(vm, "insert", new Object[]{<col1>, ... , <coln>})

Author:
kurt

Field Summary
protected  java.lang.String name
          Model name
 
Fields inherited from class com.zentense.step2.model.ResultSetModel
idName, logLevel, prepared, preparedTableId, RSConcur, RSType, table
 
Constructor Summary
AutoModel()
          Empty constructor
AutoModel(java.lang.String name, java.lang.String idName, java.lang.String tableName)
          Constructor
 
Method Summary
 void deleteCascade(AutoModel model, java.lang.String column, java.lang.Object id)
           
 void deleteCascade(java.lang.Object id)
           
 void deleteCascade(java.lang.Object id1, java.lang.Object id2)
           
 void deleteCascade(java.lang.Object id1, java.lang.Object id2, java.lang.Object id3)
           
 java.lang.String getPK(int i)
          Gets i-th primary key column name
 java.lang.String[] getPKArray()
           
 
Methods inherited from class com.zentense.step2.model.ResultSetModel
addPrepared, clearPrepared, delete, deleteAll, deleteBy, doPrepared, doQuery, doUpdate, exists, find, find, findById, genSQL, genSQL, genSQL, getAll, getAllOrderedBy, getConnection, getCount, getMaxId, getPK, getPrepared, getTableName, insertMode, insertMode, loopMode, prepare, prepareStatements, rowMode, update, updateMode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Model name

Constructor Detail

AutoModel

public AutoModel(java.lang.String name,
                 java.lang.String idName,
                 java.lang.String tableName)
Constructor


AutoModel

public AutoModel()
Empty constructor

Method Detail

getPK

public java.lang.String getPK(int i)
Gets i-th primary key column name


getPKArray

public java.lang.String[] getPKArray()

deleteCascade

public void deleteCascade(AutoModel model,
                          java.lang.String column,
                          java.lang.Object id)
                   throws java.lang.Exception
Throws:
java.lang.Exception

deleteCascade

public void deleteCascade(java.lang.Object id)
                   throws java.lang.Exception
Throws:
java.lang.Exception

deleteCascade

public void deleteCascade(java.lang.Object id1,
                          java.lang.Object id2)
                   throws java.lang.Exception
Throws:
java.lang.Exception

deleteCascade

public void deleteCascade(java.lang.Object id1,
                          java.lang.Object id2,
                          java.lang.Object id3)
                   throws java.lang.Exception
Throws:
java.lang.Exception

 

© Zentense 2008