1 22 package org.jboss.ejb.plugins.cmp.jdbc.metadata; 23 24 import java.sql.Types ; 25 26 import org.jboss.deployment.DeploymentException; 27 import org.jboss.logging.Logger; 28 29 import org.jboss.metadata.MetaData; 30 import org.w3c.dom.Element ; 31 32 40 public final class JDBCMappingMetaData 41 { 42 private static Logger log = Logger.getLogger(JDBCMappingMetaData.class.getName()); 43 44 52 public static int getJdbcTypeFromName(String name) throws DeploymentException 53 { 54 if(name == null) 55 { 56 throw new DeploymentException("jdbc-type cannot be null"); 57 } 58 59 try 60 { 61 Integer constant = (Integer )Types .class.getField(name).get(null); 62 return constant.intValue(); 63 64 } 65 catch(Exception e) 66 { 67 log.warn("Unrecognized jdbc-type: " + name + ", using Types.OTHER", e); 68 return Types.OTHER; 69 } 70 } 71 72 73 private final String javaType; 74 75 private final int jdbcType; 76 77 private final String sqlType; 78 79 private final String paramSetter; 80 81 private final String resultReader; 82 83 91 public JDBCMappingMetaData(Element element) throws DeploymentException 92 { 93 javaType = MetaData.getUniqueChildContent(element, "java-type"); 94 jdbcType = getJdbcTypeFromName(MetaData.getUniqueChildContent(element, "jdbc-type")); 95 sqlType = MetaData.getUniqueChildContent(element, "sql-type"); 96 paramSetter = MetaData.getOptionalChildContent(element, "param-setter"); 97 resultReader = MetaData.getOptionalChildContent(element, "result-reader"); 98 } 99 100 106 public String getJavaType() 107 { 108 return javaType; 109 } 110 111 117 public int getJdbcType() 118 { 119 return jdbcType; 120 } 121 122 128 public String getSqlType() 129 { 130 return sqlType; 131 } 132 133 public String getParamSetter() 134 { 135 return paramSetter; 136 } 137 138 public String getResultReader() 139 { 140 return resultReader; 141 } 142 } 143 | Popular Tags |