01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: UnboundVariable.java,v 1.4 2003/08/11 16:01:52 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import javax.jdo.JDOUserException;
14:
15: class UnboundVariable extends SQLExpression {
16: private final String name;
17: private final Class type;
18: private final JDOQLQuery.Compiler compiler;
19:
20: public UnboundVariable(QueryStatement qs, String name, Class type,
21: JDOQLQuery.Compiler compiler) {
22: super (qs);
23:
24: this .name = name;
25: this .type = type;
26: this .compiler = compiler;
27: }
28:
29: public String getVariableName() {
30: return name;
31: }
32:
33: public Class getVariableType() {
34: return type;
35: }
36:
37: public void bindTo(QueryStatement.QueryColumn qsc) {
38: StoreManager storeMgr = qs.getStoreManager();
39: DatabaseAdapter dba = storeMgr.getDatabaseAdapter();
40: Mapping m = dba.getMapping(type);
41:
42: compiler
43: .bindVariable(name, m.newSQLExpression(qs, qsc, "this"));
44: }
45:
46: public StatementText toStatementText() {
47: throw new JDOUserException(
48: "Unconstrained variable referenced: " + name);
49: }
50: }
|