aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/iciql
diff options
context:
space:
mode:
authorJames Moger <james.moger@gmail.com>2011-08-09 13:56:44 -0400
committerJames Moger <james.moger@gmail.com>2011-08-09 13:56:44 -0400
commit01ec38ed904bd24c9075edfc12c2b41c1e13d249 (patch)
tree0d2ed8b753a4bc8665703463a114750d013fbf06 /src/com/iciql
parent1a2339a9f1f96ddca64ab392dd7f9e1621e6c201 (diff)
downloadiciql-01ec38ed904bd24c9075edfc12c2b41c1e13d249.tar.gz
iciql-01ec38ed904bd24c9075edfc12c2b41c1e13d249.zip
All columns are assumed NULLABLE. IQColumn.allowNull->IQColumn.nullable
Diffstat (limited to 'src/com/iciql')
-rw-r--r--src/com/iciql/Db.java8
-rw-r--r--src/com/iciql/DbVersion.java14
-rw-r--r--src/com/iciql/Iciql.java4
-rw-r--r--src/com/iciql/TableDefinition.java10
-rw-r--r--src/com/iciql/TableInspector.java12
5 files changed, 24 insertions, 24 deletions
diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java
index 621e825..cae384d 100644
--- a/src/com/iciql/Db.java
+++ b/src/com/iciql/Db.java
@@ -236,7 +236,7 @@ public class Db {
DbVersion v = new DbVersion();
DbVersion dbVersion =
// (SCHEMA="" && TABLE="") == DATABASE
- from(v).where(v.schema).is("").and(v.table).is("").selectFirst();
+ from(v).where(v.schemaName).is("").and(v.tableName).is("").selectFirst();
if (dbVersion == null) {
// database has no version registration, but model specifies
// version: insert DbVersion entry and return.
@@ -268,14 +268,14 @@ public class Db {
// table is using iciql version tracking.
DbVersion v = new DbVersion();
String schema = StringUtils.isNullOrEmpty(model.schemaName) ? "" : model.schemaName;
- DbVersion dbVersion = from(v).where(v.schema).like(schema).and(v.table).like(model.tableName)
+ DbVersion dbVersion = from(v).where(v.schemaName).like(schema).and(v.tableName).like(model.tableName)
.selectFirst();
if (dbVersion == null) {
// table has no version registration, but model specifies
// version: insert DbVersion entry
DbVersion newTable = new DbVersion(model.tableVersion);
- newTable.schema = schema;
- newTable.table = model.tableName;
+ newTable.schemaName = schema;
+ newTable.tableName = model.tableName;
insert(newTable);
} else {
// table has a version registration:
diff --git a/src/com/iciql/DbVersion.java b/src/com/iciql/DbVersion.java
index 2a8aa44..8ccf66f 100644
--- a/src/com/iciql/DbVersion.java
+++ b/src/com/iciql/DbVersion.java
@@ -26,13 +26,13 @@ import com.iciql.Iciql.IQTable;
@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() {
@@ -47,8 +47,8 @@ public class DbVersion {
* the database version
*/
public DbVersion(int version) {
- this.schema = "";
- this.table = "";
+ this.schemaName = "";
+ this.tableName = "";
this.version = version;
}
diff --git a/src/com/iciql/Iciql.java b/src/com/iciql/Iciql.java
index 2eaf783..40c412a 100644
--- a/src/com/iciql/Iciql.java
+++ b/src/com/iciql/Iciql.java
@@ -408,9 +408,9 @@ public interface Iciql {
/**
* If false, iciql will set the column NOT NULL during the CREATE TABLE
- * phase. Default: false.
+ * phase. Default: true.
*/
- boolean allowNull() default false;
+ boolean nullable() default true;
/**
* The default value assigned to the column during the CREATE TABLE
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java
index 6e25c91..eb018bc 100644
--- a/src/com/iciql/TableDefinition.java
+++ b/src/com/iciql/TableDefinition.java
@@ -75,7 +75,7 @@ public class TableDefinition<T> {
boolean isPrimaryKey;
boolean isAutoIncrement;
boolean trimString;
- boolean allowNull;
+ boolean nullable;
String defaultValue;
EnumType enumType;
@@ -275,7 +275,7 @@ public class TableDefinition<T> {
boolean isPrimaryKey = false;
int maxLength = 0;
boolean trimString = false;
- boolean allowNull = true;
+ boolean nullable = true;
EnumType enumType = null;
String defaultValue = "";
// configure Java -> SQL enum mapping
@@ -303,7 +303,7 @@ public class TableDefinition<T> {
isPrimaryKey = col.primaryKey();
maxLength = col.length();
trimString = col.trim();
- allowNull = col.allowNull();
+ nullable = col.nullable();
// try using default object
try {
@@ -340,7 +340,7 @@ public class TableDefinition<T> {
fieldDef.isPrimaryKey = isPrimaryKey;
fieldDef.maxLength = maxLength;
fieldDef.trimString = trimString;
- fieldDef.allowNull = allowNull;
+ fieldDef.nullable = nullable;
fieldDef.defaultValue = defaultValue;
fieldDef.enumType = enumType;
fieldDef.dataType = ModelUtils.getDataType(fieldDef, strictTypeMapping);
@@ -562,7 +562,7 @@ public class TableDefinition<T> {
buff.append(" AUTO_INCREMENT");
}
- if (!field.allowNull) {
+ if (!field.nullable) {
buff.append(" NOT NULL");
}
diff --git a/src/com/iciql/TableInspector.java b/src/com/iciql/TableInspector.java
index 6ec848d..51b2d69 100644
--- a/src/com/iciql/TableInspector.java
+++ b/src/com/iciql/TableInspector.java
@@ -139,7 +139,7 @@ public class TableInspector {
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))) {
@@ -158,7 +158,7 @@ public class TableInspector {
/**
* 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
@@ -369,9 +369,9 @@ public class TableInspector {
}
}
- // IQColumn.allowNull
- if (!col.allowNull) {
- ap.addParameter("allowNull=false");
+ // IQColumn.nullable
+ if (!col.nullable) {
+ ap.addParameter("nullable=false");
}
// IQColumn.defaultValue
@@ -622,7 +622,7 @@ public class TableInspector {
String name;
String type;
int size;
- boolean allowNull;
+ boolean nullable;
Class<?> clazz;
boolean isPrimaryKey;
boolean isAutoIncrement;