*/
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.
}\r
\r
@Override\r
- public DataTypeAdapter<?> getTypeAdapter(Class<? extends DataTypeAdapter<?>> typeAdapter) {\r
+ public void registerAdapter(DataTypeAdapter<?> typeAdapter) {\r
+ typeAdapters.put((Class<? extends DataTypeAdapter<?>>) typeAdapter.getClass(), typeAdapter);\r
+ }\r
+\r
+ @Override\r
+ public DataTypeAdapter<?> getAdapter(Class<? extends DataTypeAdapter<?>> typeAdapter) {\r
DataTypeAdapter<?> dtt = typeAdapters.get(typeAdapter);\r
if (dtt == null) {\r
dtt = Utils.newObject(typeAdapter);\r
return value;\r
}\r
\r
- DataTypeAdapter<T> dtt = (DataTypeAdapter<T>) getTypeAdapter(typeAdapter);\r
+ DataTypeAdapter<T> dtt = (DataTypeAdapter<T>) getAdapter(typeAdapter);\r
return dtt.serialize(value);\r
}\r
\r
\r
if (col.typeAdapter() != null && col.typeAdapter() != StandardJDBCTypeAdapter.class) {\r
typeAdapter = col.typeAdapter();\r
- DataTypeAdapter<?> dtt = db.getDialect().getTypeAdapter(col.typeAdapter());\r
+ DataTypeAdapter<?> dtt = db.getDialect().getAdapter(col.typeAdapter());\r
dataType = dtt.getDataType();\r
}\r
\r