SQL parameter container
https://gyazo.com/c5a54e42fa7375ac79471952da4e2314 #Core #Types
What Java class is SQL parameter container
Sorm4j treats any Java class is regarded as SQL parameter container.
* A column name in SQL and a field accessor name of the container object are compared based on Canonical name. Columns are mapped fields accessors of container class with the following rules.
Rule 1: The method annotated @OrmGetter (field accessor name is the value of annotation)
Rule 2: The field annotated @OrmColumn (field accessor name is the value of annotation)
Rule 3: getX method (field accessor name is trim set/get from setter/getter)
Rule 4: Direct field access (field accessor name is the filed name)
Rule 5: public method (field accessor name is the method name. This rule is for Record class) which has no parameter and returns a value.
How to map SQL parameter container to table (insert, update, delete,...)
SQL parameters container class will be mapped with a table on the database when a insert, update, delete method is called. The table - parameter container class mapping is depend on the class name or @OrmTable annotation. By default, the simple class name of the container object is regarded as the table name.
After a mapping is created, Sorm can perform CRUD operations directly on instances of the SQL parameter container. At first time to use a container class, Sorm will build a mapping automatically and cache it.
The readX operations which work with Results container are not required mapping to table.
Mapping rules
Table name candidates and table name on database are comparing based on Canonical name.
Table name candidates are generated by following rule (preferential order):
Rule 1: If the container class is annotated with @OrmTable, the value, the value with s and the value with es (and the value trimmed last y and added ies) become table name candidates.
Rule 2: If the container class is without @OrmTable annotation, the simple class name (java.lang.Class#getSimpleName) is regarded as the table name candidate.
How to map SQL parameter container to table (insertIn, updateIn, deleteIn, mergeIn)
SQL parameter container will be mapped with a table when a insertIn, updateIn, deleteIn, mergeIn method is called. The table - parameter container class mapping is depend on the method arguments.
Example
@see> Binding Java object to SQL parameters