1 10 11 package com.triactive.jdo.store; 12 13 import javax.jdo.JDOUserException; 14 15 16 class UnboundVariable extends SQLExpression 17 { 18 private final String name; 19 private final Class type; 20 private final JDOQLQuery.Compiler compiler; 21 22 public UnboundVariable(QueryStatement qs, String name, Class type, JDOQLQuery.Compiler compiler) 23 { 24 super(qs); 25 26 this.name = name; 27 this.type = type; 28 this.compiler = compiler; 29 } 30 31 public String getVariableName() 32 { 33 return name; 34 } 35 36 public Class getVariableType() 37 { 38 return type; 39 } 40 41 public void bindTo(QueryStatement.QueryColumn qsc) 42 { 43 StoreManager storeMgr = qs.getStoreManager(); 44 DatabaseAdapter dba = storeMgr.getDatabaseAdapter(); 45 Mapping m = dba.getMapping(type); 46 47 compiler.bindVariable(name, m.newSQLExpression(qs, qsc, "this")); 48 } 49 50 public StatementText toStatementText() 51 { 52 throw new JDOUserException("Unconstrained variable referenced: " + name); 53 } 54 } 55 | Popular Tags |