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: SubquerySetExpression.java,v 1.1 2003/08/11 16:01:51 pierreg0 Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import javax.jdo.JDOFatalInternalException;
14:
15: /**
16: * A set expression whose contents are expressed as a SQL subquery.
17: *
18: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
19: * @version $Revision: 1.1 $
20: */
21:
22: class SubquerySetExpression extends SetExpression {
23: private final QueryStatement subquery;
24:
25: public SubquerySetExpression(QueryStatement qs,
26: QueryStatement subquery) {
27: super (qs);
28:
29: this .subquery = subquery;
30:
31: if (subquery.columnsSelected() != 1)
32: throw new JDOFatalInternalException(
33: "Cannot use as set expression, # of selected columns != 1: "
34: + subquery);
35:
36: st.append("(").append(subquery.toStatementText()).append(')');
37: }
38:
39: public BooleanExpression containsMethod(SQLExpression expr) {
40: return expr.in(this );
41: }
42:
43: public BooleanExpression isEmptyMethod() {
44: return new ExistsExpression(qs, subquery, false);
45: }
46: }
|