diff options
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/iciql/SQLDialect.java | 9 | ||||
-rw-r--r-- | src/main/java/com/iciql/SQLDialectDefault.java | 9 | ||||
-rw-r--r-- | src/main/java/com/iciql/TableDefinition.java | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/main/java/com/iciql/SQLDialect.java b/src/main/java/com/iciql/SQLDialect.java index 8937baf..7c45cc2 100644 --- a/src/main/java/com/iciql/SQLDialect.java +++ b/src/main/java/com/iciql/SQLDialect.java @@ -32,12 +32,19 @@ import com.iciql.TableDefinition.IndexDefinition; public interface SQLDialect { /** + * Registers the type adapter instance. + * + * @param typeAdapter + */ + void registerAdapter(DataTypeAdapter<?> typeAdapter); + + /** * Returns the registered instance of the type adapter. * * @param typeAdapter * @return the type adapter instance */ - DataTypeAdapter<?> getTypeAdapter(Class<? extends DataTypeAdapter<?>> typeAdapter); + DataTypeAdapter<?> getAdapter(Class<? extends DataTypeAdapter<?>> typeAdapter); /** * Serialize the Java object into a type or format that the database will accept. diff --git a/src/main/java/com/iciql/SQLDialectDefault.java b/src/main/java/com/iciql/SQLDialectDefault.java index 7789412..bcfa64f 100644 --- a/src/main/java/com/iciql/SQLDialectDefault.java +++ b/src/main/java/com/iciql/SQLDialectDefault.java @@ -345,7 +345,12 @@ public class SQLDialectDefault implements SQLDialect { }
@Override
- public DataTypeAdapter<?> getTypeAdapter(Class<? extends DataTypeAdapter<?>> typeAdapter) {
+ public void registerAdapter(DataTypeAdapter<?> typeAdapter) {
+ typeAdapters.put((Class<? extends DataTypeAdapter<?>>) typeAdapter.getClass(), typeAdapter);
+ }
+
+ @Override
+ public DataTypeAdapter<?> getAdapter(Class<? extends DataTypeAdapter<?>> typeAdapter) {
DataTypeAdapter<?> dtt = typeAdapters.get(typeAdapter);
if (dtt == null) {
dtt = Utils.newObject(typeAdapter);
@@ -362,7 +367,7 @@ public class SQLDialectDefault implements SQLDialect { return value;
}
- DataTypeAdapter<T> dtt = (DataTypeAdapter<T>) getTypeAdapter(typeAdapter);
+ DataTypeAdapter<T> dtt = (DataTypeAdapter<T>) getAdapter(typeAdapter);
return dtt.serialize(value);
}
diff --git a/src/main/java/com/iciql/TableDefinition.java b/src/main/java/com/iciql/TableDefinition.java index 4536695..7857a5a 100644 --- a/src/main/java/com/iciql/TableDefinition.java +++ b/src/main/java/com/iciql/TableDefinition.java @@ -534,7 +534,7 @@ public class TableDefinition<T> { if (col.typeAdapter() != null && col.typeAdapter() != StandardJDBCTypeAdapter.class) {
typeAdapter = col.typeAdapter();
- DataTypeAdapter<?> dtt = db.getDialect().getTypeAdapter(col.typeAdapter());
+ DataTypeAdapter<?> dtt = db.getDialect().getAdapter(col.typeAdapter());
dataType = dtt.getDataType();
}
|