01: /*
02: * Copyright 2004 (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: Mapping.java,v 1.5 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: /**
14: * An object that maps between a Java type and its relational representation
15: * in the data store.
16: * <p>
17: * Subclasses of Mapping define and perform the storage and retrieval functions
18: * for a particular Java type.
19: * They also assist in arbitrary SQL generation such as done during Query
20: * compilation.
21: * <p>
22: * Individual Mapping objects are sometimes bound to specific database tables
23: * or columns, and are re-used for all data transfers.
24: * Other times a Mapping is merely prototypical, and is used for transferring
25: * to or from any suitable table/column.
26: *
27: * @author <a href="mailto:mmartin5@austin.rr.com">Mike Martin</a>
28: * @version $Revision: 1.5 $
29: *
30: * @see DatabaseAdapter#getMapping(Class)
31: * @see DatabaseAdapter#getMapping(ClassBaseTable,int)
32: */
33:
34: public abstract class Mapping {
35: protected final DatabaseAdapter dba;
36: protected final Class type;
37:
38: /**
39: * Create a new Mapping with the given DatabaseAdapter for the given type.
40: *
41: * @param dba The DatabaseAdapter that this Mapping should use.
42: * @param type The Class that this mapping maps to the database.
43: */
44: protected Mapping(DatabaseAdapter dba, Class type) {
45: this .dba = dba;
46: this .type = type;
47: }
48:
49: /**
50: * Return the Class that this Mapping maps to the database.
51: *
52: * @return The Class that this Mapping maps to the database.
53: */
54: public Class getType() {
55: return type;
56: }
57:
58: public abstract SQLExpression newSQLLiteral(QueryStatement qs,
59: Object value);
60:
61: public abstract SQLExpression newSQLExpression(QueryStatement qs,
62: TableExpression te, String fieldName);
63:
64: public abstract SQLExpression newSQLExpression(QueryStatement qs,
65: QueryStatement.QueryColumn qsc, String fieldName);
66: }
|