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: PersistenceCapableMapping.java,v 1.5 2004/01/18 03:01:06 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: import com.triactive.jdo.PersistenceManager;
14: import java.sql.PreparedStatement;
15: import java.sql.ResultSet;
16: import javax.jdo.JDOUserException;
17: import javax.jdo.spi.PersistenceCapable;
18:
19: public class PersistenceCapableMapping extends OIDMapping {
20: private Class surroundingClass = null;
21:
22: public PersistenceCapableMapping(DatabaseAdapter dba, Class type) {
23: super (dba, type);
24: }
25:
26: public PersistenceCapableMapping(Column col) {
27: super (col);
28: }
29:
30: public PersistenceCapableMapping(ClassBaseTable table,
31: int relativeFieldNumber) {
32: this (table.newColumn(relativeFieldNumber));
33:
34: surroundingClass = table.getType();
35: }
36:
37: public void setObject(PersistenceManager pm, PreparedStatement ps,
38: int param, Object value) {
39: pm.makePersistent(value);
40: super .setObject(pm, ps, param, pm.getObjectId(value));
41: }
42:
43: public Object getObject(PersistenceManager pm, ResultSet rs,
44: int param) {
45: return pm.getObjectById(super .getObject(pm, rs, param),
46: surroundingClass, false);
47: }
48:
49: public SQLExpression newSQLLiteral(QueryStatement qs, Object value) {
50: return new ObjectLiteral(qs, this , value);
51: }
52:
53: public SQLExpression newSQLExpression(QueryStatement qs,
54: QueryStatement.QueryColumn qsc, String fieldName) {
55: return new ObjectFieldExpression(qs, qsc, fieldName, type);
56: }
57: }
|