User: dsundstrom
Date: 01/08/19 15:50:33
Modified: src/main/org/jboss/ejb/plugins/cmp/jdbc/metadata
JDBCTypeMappingMetaData.java
Log:
Added function mapping for EJB-QL.
Revision Changes Path
1.4 +81 -2
jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java
Index: JDBCTypeMappingMetaData.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/ejb/plugins/cmp/jdbc/metadata/JDBCTypeMappingMetaData.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- JDBCTypeMappingMetaData.java 2001/08/03 17:15:47 1.3
+++ JDBCTypeMappingMetaData.java 2001/08/19 22:50:33 1.4
@@ -18,7 +18,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Dain Sundstrom</a>
* @author <a href="[EMAIL PROTECTED]">Sebastien Alborini</a>
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
*/
public final class JDBCTypeMappingMetaData {
@@ -29,6 +29,8 @@
private final String name;
private final HashMap mappings = new HashMap();
+
+ private final HashMap functionMappings = new HashMap();
/**
* Constructs a mapping with the data contained in the type-mapping xml element
@@ -46,11 +48,21 @@
// get the mappings
Iterator iterator = MetaData.getChildrenByTagName(element, "mapping");
- while (iterator.hasNext()) {
+ while(iterator.hasNext()) {
Element mappingElement = (Element)iterator.next();
JDBCMappingMetaData mapping = new
JDBCMappingMetaData(mappingElement);
mappings.put(mapping.getJavaType(), mapping);
}
+
+ addDefaultFunctionMapping();
+
+ // get the mappings
+ Iterator functions = MetaData.getChildrenByTagName(element,
"function-mapping");
+ while(functions.hasNext()) {
+ Element mappingElement = (Element)functions.next();
+ JDBCFunctionMappingMetaData functionMapping = new
JDBCFunctionMappingMetaData(mappingElement);
+
functionMappings.put(functionMapping.getFunctionName().toLowerCase(), functionMapping);
+ }
}
/**
@@ -122,5 +134,72 @@
}
return mapping.getSqlType();
+ }
+
+ public JDBCFunctionMappingMetaData getFunctionMapping(String name) {
+ return
(JDBCFunctionMappingMetaData)functionMappings.get(name.toLowerCase());
+ }
+
+ private void addDefaultFunctionMapping() {
+ JDBCFunctionMappingMetaData function;
+
+ // concat
+ function = new JDBCFunctionMappingMetaData("concat",
+ new String[] {
+ "{fn concat(",
+ ", ",
+ ")}"
+ },
+ new int[] {0, 1} );
+ functionMappings.put(function.getFunctionName().toLowerCase(),
function);
+
+ // substring
+ function = new JDBCFunctionMappingMetaData("substring",
+ new String[] {
+ "{fn substring(",
+ ", ",
+ ", ",
+ ")}"
+ },
+ new int[] {0, 1, 2} );
+ functionMappings.put(function.getFunctionName().toLowerCase(),
function);
+
+ // length
+ function = new JDBCFunctionMappingMetaData("length",
+ new String[] {
+ "{fn length(",
+ ")}"
+ },
+ new int[] {0} );
+ functionMappings.put(function.getFunctionName().toLowerCase(),
function);
+
+ // locate
+ function = new JDBCFunctionMappingMetaData("locate",
+ new String[] {
+ "{fn locate(",
+ ", ",
+ ", ",
+ ")}"
+ },
+ new int[] {0, 1, 2} );
+ functionMappings.put(function.getFunctionName().toLowerCase(),
function);
+
+ // abs
+ function = new JDBCFunctionMappingMetaData("abs",
+ new String[] {
+ "{fn abs(",
+ ")}"
+ },
+ new int[] {0} );
+ functionMappings.put(function.getFunctionName().toLowerCase(),
function);
+
+ // sqrt
+ function = new JDBCFunctionMappingMetaData("sqrt",
+ new String[] {
+ "{fn sqrt(",
+ ")}"
+ },
+ new int[] {0} );
+ functionMappings.put(function.getFunctionName().toLowerCase(),
function);
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development