### Configuration Requirements and Limitations\r
\r
1. Your model class **must** provide a public default constructor.\r
-2. Only the specified types are supported. Other types such as arrays and custom types are not supported.\r
-3. Triggers, views, and other advanced database features are not supported.\r
+2. All columns are assumed NULLABLE unless explicitly set *@IQColumn(nullable = false)*. \r
+3. Only the specified types are supported. Other types such as arrays and custom types are not supported.\r
+4. Triggers, views, and other advanced database features are not supported.\r
\r
### Fully Supported Data Types\r
The following data types can be used for all iciql expressions.\r
**%VERSION%** ([zip](http://code.google.com/p/iciql/downloads/detail?name=%ZIP%)|[jar](http://code.google.com/p/iciql/downloads/detail?name=%JAR%)) *released %BUILDDATE%*\r
\r
- api change release (API v4)\r
+- @IQColumn(allowNull=true) -> @IQColumn(nullable=true)\r
+- All columns are assumed NULLABLE unless explicitly set *@IQColumn(nullable = false)*\r
- allow using objects to assign default values<br/>\r
%BEGINCODE%\r
// CREATE TABLE ... myDate DATETIME DEFAULT '2000-02-01 00:00:00'\r
DbVersion v = new DbVersion();\r
DbVersion dbVersion =\r
// (SCHEMA="" && TABLE="") == DATABASE\r
- from(v).where(v.schema).is("").and(v.table).is("").selectFirst();\r
+ from(v).where(v.schemaName).is("").and(v.tableName).is("").selectFirst();\r
if (dbVersion == null) {\r
// database has no version registration, but model specifies\r
// version: insert DbVersion entry and return.\r
// table is using iciql version tracking.\r
DbVersion v = new DbVersion();\r
String schema = StringUtils.isNullOrEmpty(model.schemaName) ? "" : model.schemaName;\r
- DbVersion dbVersion = from(v).where(v.schema).like(schema).and(v.table).like(model.tableName)\r
+ DbVersion dbVersion = from(v).where(v.schemaName).like(schema).and(v.tableName).like(model.tableName)\r
.selectFirst();\r
if (dbVersion == null) {\r
// table has no version registration, but model specifies\r
// version: insert DbVersion entry\r
DbVersion newTable = new DbVersion(model.tableVersion);\r
- newTable.schema = schema;\r
- newTable.table = model.tableName;\r
+ newTable.schemaName = schema;\r
+ newTable.tableName = model.tableName;\r
insert(newTable);\r
} else {\r
// table has a version registration:\r
@IQTable(name = "_iq_versions", primaryKey = { "schemaName", "tableName"}, memoryTable = true)
public class DbVersion {
- @IQColumn(name = "schemaName", length = 255, allowNull = false)
- String schema = "";
+ @IQColumn(length = 255)
+ String schemaName = "";
- @IQColumn(name = "tableName", length = 255, allowNull = false)
- String table = "";
+ @IQColumn(length = 255)
+ String tableName = "";
- @IQColumn(name = "version")
+ @IQColumn
Integer version;
public DbVersion() {
* the database version
*/
public DbVersion(int version) {
- this.schema = "";
- this.table = "";
+ this.schemaName = "";
+ this.tableName = "";
this.version = version;
}
\r
/**\r
* If false, iciql will set the column NOT NULL during the CREATE TABLE\r
- * phase. Default: false.\r
+ * phase. Default: true.\r
*/\r
- boolean allowNull() default false;\r
+ boolean nullable() default true;\r
\r
/**\r
* The default value assigned to the column during the CREATE TABLE\r
boolean isPrimaryKey;\r
boolean isAutoIncrement;\r
boolean trimString;\r
- boolean allowNull;\r
+ boolean nullable;\r
String defaultValue;\r
EnumType enumType;\r
\r
boolean isPrimaryKey = false;\r
int maxLength = 0;\r
boolean trimString = false;\r
- boolean allowNull = true;\r
+ boolean nullable = true;\r
EnumType enumType = null;\r
String defaultValue = "";\r
// configure Java -> SQL enum mapping\r
isPrimaryKey = col.primaryKey();\r
maxLength = col.length();\r
trimString = col.trim();\r
- allowNull = col.allowNull();\r
+ nullable = col.nullable();\r
\r
// try using default object\r
try {\r
fieldDef.isPrimaryKey = isPrimaryKey;\r
fieldDef.maxLength = maxLength;\r
fieldDef.trimString = trimString;\r
- fieldDef.allowNull = allowNull;\r
+ fieldDef.nullable = nullable;\r
fieldDef.defaultValue = defaultValue;\r
fieldDef.enumType = enumType;\r
fieldDef.dataType = ModelUtils.getDataType(fieldDef, strictTypeMapping);\r
buff.append(" AUTO_INCREMENT");\r
}\r
\r
- if (!field.allowNull) {\r
+ if (!field.nullable) {\r
buff.append(" NOT NULL");\r
}\r
\r
col.type = rs.getString("TYPE_NAME");
col.clazz = ModelUtils.getClassForSqlType(col.type, dateTimeClass);
col.size = rs.getInt("COLUMN_SIZE");
- col.allowNull = rs.getInt("NULLABLE") == DatabaseMetaData.columnNullable;
+ col.nullable = rs.getInt("NULLABLE") == DatabaseMetaData.columnNullable;
col.isAutoIncrement = rs.getBoolean("IS_AUTOINCREMENT");
if (primaryKeys.size() == 1) {
if (col.name.equalsIgnoreCase(primaryKeys.get(0))) {
/**
* Generates a model (class definition) from this table. The model includes
- * indexes, primary keys, default values, maxLengths, and allowNull
+ * indexes, primary keys, default values, lengths, and nullables.
* information.
* <p>
* The caller may optionally set a destination package name, whether or not
}
}
- // IQColumn.allowNull
- if (!col.allowNull) {
- ap.addParameter("allowNull=false");
+ // IQColumn.nullable
+ if (!col.nullable) {
+ ap.addParameter("nullable=false");
}
// IQColumn.defaultValue
String name;
String type;
int size;
- boolean allowNull;
+ boolean nullable;
Class<?> clazz;
boolean isPrimaryKey;
boolean isAutoIncrement;
true);
assertEquals(1, models.size());
// a poor test, but a start
- assertEquals(1780, models.get(0).length());
+ assertEquals(1456, models.get(0).length());
}
@Test
@IQEnum(EnumType.ORDINAL)\r
public Tree myOrdinalTree = Tree.PINE;\r
\r
- @IQColumn(allowNull = true)\r
+ @IQColumn(nullable = true)\r
public Tree myNullTree;\r
\r
public DefaultValuesModel() {\r