1 22 package org.jboss.ejb.plugins.cmp.jdbc.metadata; 23 24 import java.lang.reflect.Method ; 25 26 import org.jboss.deployment.DeploymentException; 27 28 34 public final class JDBCDynamicQLQueryMetaData implements JDBCQueryMetaData 35 { 36 39 private final Method method; 40 41 44 private final boolean resultTypeMappingLocal; 45 46 private final JDBCReadAheadMetaData readAhead; 47 48 private final Class compiler; 49 50 private final boolean lazyResultSetLoading; 51 52 58 public JDBCDynamicQLQueryMetaData(JDBCDynamicQLQueryMetaData defaults, 59 JDBCReadAheadMetaData readAhead, 60 Class qlCompiler, 61 boolean lazyResultSetLoading) 62 throws DeploymentException 63 { 64 this.method = defaults.getMethod(); 65 this.readAhead = readAhead; 66 this.resultTypeMappingLocal = defaults.isResultTypeMappingLocal(); 67 compiler = qlCompiler; 68 this.lazyResultSetLoading = lazyResultSetLoading; 69 } 70 71 72 76 public JDBCDynamicQLQueryMetaData(boolean resultTypeMappingLocal, 77 Method method, 78 JDBCReadAheadMetaData readAhead, 79 Class compiler, 80 boolean lazyResultSetLoading) 81 throws DeploymentException 82 { 83 84 this.method = method; 85 this.readAhead = readAhead; 86 this.resultTypeMappingLocal = resultTypeMappingLocal; 87 88 Class [] parameterTypes = method.getParameterTypes(); 89 if(parameterTypes.length != 2 90 || 91 !parameterTypes[0].equals(String .class) || 92 !parameterTypes[1].equals(Object [].class)) 93 { 94 throw new DeploymentException( 95 "Dynamic-ql method must have two " + 96 "parameters of type String and Object[]." 97 ); 98 } 99 100 this.compiler = compiler; 101 this.lazyResultSetLoading = lazyResultSetLoading; 102 } 103 104 public Method getMethod() 106 { 107 return method; 108 } 109 110 public boolean isResultTypeMappingLocal() 112 { 113 return resultTypeMappingLocal; 114 } 115 116 121 public JDBCReadAheadMetaData getReadAhead() 122 { 123 return readAhead; 124 } 125 126 public Class getQLCompilerClass() 127 { 128 return compiler; 129 } 130 131 public boolean isLazyResultSetLoading() 132 { 133 return lazyResultSetLoading; 134 } 135 136 145 public boolean equals(Object o) 146 { 147 if(o instanceof JDBCDynamicQLQueryMetaData) 148 { 149 return ((JDBCDynamicQLQueryMetaData) o).method.equals(method); 150 } 151 return false; 152 } 153 154 160 public int hashCode() 161 { 162 return method.hashCode(); 163 } 164 165 175 public String toString() 176 { 177 return "[JDBCDynamicQLQueryMetaData : method=" + method + "]"; 178 } 179 } 180 | Popular Tags |