aboutsummaryrefslogtreecommitdiffstats
path: root/docs/01_model_classes.mkd
diff options
context:
space:
mode:
Diffstat (limited to 'docs/01_model_classes.mkd')
-rw-r--r--docs/01_model_classes.mkd92
1 files changed, 76 insertions, 16 deletions
diff --git a/docs/01_model_classes.mkd b/docs/01_model_classes.mkd
index 6e58f0a..846ef6c 100644
--- a/docs/01_model_classes.mkd
+++ b/docs/01_model_classes.mkd
@@ -5,9 +5,16 @@ Models can be manually written using one of two approaches: *annotation configur
Alternatively, model classes can be automatically generated by iciql using the model generation tool. Please see the [tools](tools.html) page for details.
-### Supported Data Types
-<table>
+### Configuration Requirements and Limitations
+
+1. Your model class **must** provide a public default constructor.
+2. Only the specified types are supported. Other types such as arrays and custom types are not supported.
+3. Triggers, views, and other advanced database features are not supported.
+### Fully Supported Data Types
+The following data types can be used for all iciql expressions.
+<table>
+<tr><th colspan="2">All Databases</th></tr>
<tr><td>java.lang.String</td>
<td>VARCHAR *(length > 0)* or TEXT *(length == 0)*</td></tr>
@@ -47,11 +54,8 @@ Alternatively, model classes can be automatically generated by iciql using the m
<tr><td>java.util.Date</td>
<td>TIMESTAMP</td></tr>
-<tr><td>byte []</td>
-<td>BLOB</td></tr>
-
-<tr><td>java.lang.Enum.name()</td>
-<td>VARCHAR *(length > 0)* or TEXT *(length == 0)*<br/>*EnumType.STRING*</td></tr>
+<tr><td>java.lang.Enum.name()<br/>*default type*</td>
+<td>VARCHAR *(length > 0)* or TEXT *(length == 0)*<br/>*EnumType.NAME*</td></tr>
<tr><td>java.lang.Enum.ordinal()</td>
<td>INT<br/>*EnumType.ORDINAL*</td></tr>
@@ -59,23 +63,79 @@ Alternatively, model classes can be automatically generated by iciql using the m
<tr><td>java.lang.Enum implements<br/>*com.iciql.Iciql.EnumId.enumId()*</td>
<td>INT<br/>*EnumType.ENUMID*</td></tr>
+<tr><th colspan="2">H2 Databases</th></tr>
+<tr><td>java.util.UUID</td>
+<td>UUID</td><tr/>
+
</table>
**NOTE:**<br/>
The reverse lookup used for model generation, SQL type -> Java type, contains more mappings.<br/>
Please consult the `com.iciql.ModelUtils` class for details.
-### Unsupported Types
-- Java primitives (use their object counterparts instead)
-- array types
-- custom types
+### Partially Supported Data Types
+The following data types can be mapped to columns for all general statements <u>BUT</u> these field types may **not** be used to specify **compile-time** *clauses or constraints*.
+
+<table>
+<tr><td>byte []</td>
+<td>BLOB</td></tr>
+
+<tr><td>boolean</td>
+<td>BIT</td></tr>
+
+<tr><td>byte</td>
+<td>TINYINT</td></tr>
+
+<tr><td>short</td>
+<td>SMALLINT</td></tr>
+
+<tr><td>int</td>
+<td>INT</td></tr>
+
+<tr><td>long</td>
+<td>BIGINT</td></tr>
+
+<tr><td>float</td>
+<td>REAL</td></tr>
+
+<tr><td>double</td>
+<td>DOUBLE</td></tr>
+
+</table>
-### Configuration Rules
-1. field mappings must be Objects not primitives
-2. the model class must have a default public constructor
+#### Partially Supported Data Types Example
+%BEGINCODE%
+class Primitives {
+ @IQColumn(primaryKey = true)
+ int id;
+
+ @IQColumn
+ String name;
+
+ public Primitives() {
+ }
+
+ public Primitives(int id, String name) {
+ this.id = id;
+ this.name = name;
+ }
+}
+
+Primitives p = new Primitives();
+
+// the following expressions compile, but will throw iciql runtime exceptions
+db.from(p).where(p.id).is(100).selectFirst();
+db.from(p).where(p.id).atLeast(10).select();
+
+// the following expressions will work as expected
+db.from(p).select();
+db.from(p).where("id = ?", 100).selectFirst();
+db.from(p).where("id >= ?", 10).select();
+db.insert(new Primitives(150, "test"));
+db.update(new Primitives(150, "modified"));
+db.delete(new Primitives(150, "test"));
+%ENDCODE%
-### Configuration Limitations
-Triggers, views, and other advanced database features are unimplemented.
## Annotation Configuration
The recommended approach to setup a model class is to annotate the class and field declarations.